/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package function;

import engine.goods.Goods;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Graphics;
import mainpackage.Constant;
import mainpackage.MainLogic;
import mainpackage.MainCanvas;
import mainpackage.GameBean;
import mainpackage.MainView;
import mainpackage.ResManager;
import mainpackage.Tools;
import mainpackage.MainGame;
import mainpackage.InputInterFace;
import ui.UiInterFace;

/**
 *
 * @author foonwayx
 */
public class Store {
    //ui界面的起始点坐标

    private int iPositionY = 0; //用来记录选择线的位置
    private int[] iArray;
    private int iStartPointY;   //包裹栏开始的位置
    private Image[] imgArray;
    public String[] sArray;
    private boolean bKeypressLock = false; //键盘锁
    private int iCount = 0;  //计数
    private boolean bFlag;
    private boolean bLock;
    public boolean bWaitMSGBack = false;  //从网络获得物品的简单描述，防止重复发送
    public byte bySelectIndex; //一级选中状态。从1开始
    public byte bySubSelectIndex; //子选择索引
    private byte byMenuIndex;//物品操作选项索引
    private byte byTotalPage = 1; //总的页数
    public byte byCurrentPage = 1;  //当前页数
    private byte byNumPerPage = 28; //每页显示的格子数量
    public byte byUiState = 0; //界面UI状态
    public long lMoney = 0L; //钱数量（单位铜币）
    public long lTradeMoney = 0L;
    private long lastSendDescTime = 0L; //最后向网络请求物品描述的时间
    public String[] sOpArray = null; //被选中的物品的可操作的选项
    private byte byState;  //界面操作中记录小的状态
    private int iStartX;
    private int iStartY;
    public short shPos = 0;  //当前物品索引
    public static short shGetNetDescPos = -1; //记录动态获得物品描述的索引
    public static byte byPopUpState = 1;
//    public short shHeight = 0;
    public Goods items;
    public Goods myItems; //与其他玩家的交易的物品 
    public byte byButtonSelectIndex = 1;
    public long lTraderID = -1L;
    public String sTrader = null;
    public boolean[] bTradeLock;
    public short[] shSelectIndex;
    public byte byBuyGoodsNum = 0;
    public String sShopTitle = null;
    public int iGoodsDescHeight = 0;
    public short shMaxColumnNum;  //仓库可最大数量
    public byte byWareHouseType; //仓库类型(1,玩家仓库，2，帮派仓库)
    public long lNpcID;
    public byte byOpState;
    public byte byStoreType = 0;//商店类型(1,普通，2，帮派徽记兑换,3:牌子兑换)
    private int[] iBrand;//记录牌子数量(0龙睛`1追星2凤瞳3七杀),
    private int[] iBrandPrice;//记录每个物品的牌子价格
    public Goods[] store;
    public byte byTabIndex;
    public byte byGetNetDescTabIndex;
    public byte byGetNetDescType;
    private short shPlayerBag; //玩家背包数量
    private short shPlayerNowBag;//玩家当前背包数量
    private String[] sIngotTabTitle;//元宝商城的标签
    public long lPlayerMoney = -1;
    public String sTips;
    public short shTipsW;
    public short shTipsH;
    public short shTipsIngotPicStart;

    /***************************购买物品界面*****************************************************************/
    public void lockPlayerSkillBook() {
        if (this.items == null) {
            return;
        }
        short max = this.items.getMaxColumNum();
        for (byte i = 0; i < max; i++) {
            if (this.items.getGoodsJob(i) == MainLogic.getInstance().gamePlayer.iplayerOccupation) {
                this.shPos = i;
                this.byCurrentPage = (byte) Tools.ceil(this.shPos + 1, 28);
                this.bySelectIndex = (byte) ((this.shPos - (this.byCurrentPage - 1) * 28) / 7 + 1);
                this.setGoodsState(this.items, this.shPos);
                break;
            }
        }

    }

    /**
     * 打开npc商店和牌子帮派兑换
     * @param byStoreType //商店lexington
     * @param lMoney  //玩家的游戏币
     * @param iTongEmblem //帮派徽记
     * @param iDragonEye  //龙睛
     * @param iStar //追星
     * @param iPhenixEye //凤瞳
     * @param iSevenKill  //七杀
     */
    public void setNpcStore(byte byStoreType, String sShopTitle, long lMoney, int iTongEmblem, int iDragonEye, int iStar, int iPhenixEye, int iSevenKill, int[] iBrandPrice) {
        this.byStoreType = byStoreType;
        this.sShopTitle = sShopTitle;
        switch (this.byStoreType) {
            case 1:
                this.lMoney = lMoney;//游戏币
                break;
            case 2:
                //牌子兑换
                this.iBrand = new int[]{iDragonEye, iStar, iPhenixEye, iSevenKill};//牌子
                this.iBrandPrice = iBrandPrice;
                break;
            case 3:
                this.lMoney = iTongEmblem;//帮派徽记
                break;
        }
        MainLogic.getInstance().pushState(Constant.GAME_UI_STORE_BUY, true);
    }

    /*****
     * 物品购买结果
     */
    public void setBuyGoods(byte stateCode) {
        switch (stateCode) {
            case 0:
                if (GameBean.BY_TYPE == 1) {
                    switch (this.byStoreType) {
                        case 1:
                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品购买失败");
                            break;
                        case 2:
                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品兑换失败");
                            break;
                        case 3:
                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品兑换失败");
                            break;
                        case 4:
                        case 5:
                        case 6:
                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品兑换失败!");
                            break;
                    }
                } else {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "道具出售失败");
                }
                break;
            case 1:
//                System.out.println("GameBean.BY_TYPEww  " + GameBean.BY_TYPE);
//                System.out.println("byStoreType  " + this.byStoreType);
                if (GameBean.BY_TYPE == 1) {
                    switch (this.byStoreType) {
                        case 1:
                            this.lMoney -= this.items.getGoodsPrice(shPos) * this.byBuyGoodsNum;
                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品购买成功");
                            break;
                        case 2:
                            this.iBrand[0] -= this.iBrandPrice[shPos * 4] * this.byBuyGoodsNum;
                            this.iBrand[1] -= this.iBrandPrice[shPos * 4 + 1] * this.byBuyGoodsNum;
                            this.iBrand[2] -= this.iBrandPrice[shPos * 4 + 2] * this.byBuyGoodsNum;
                            this.iBrand[3] -= this.iBrandPrice[shPos * 4 + 3] * this.byBuyGoodsNum;
                            this.sArray[4] = "龙睛 " + this.iBrand[0] + "追星 " + this.iBrand[1] + "|凤瞳 " + this.iBrand[2] + "七杀 " + this.iBrand[3];
                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品兑换成功");
                            break;
                        case 3:
                            this.lMoney -= this.items.getGoodsPrice(shPos) * this.byBuyGoodsNum;
                            this.sArray[4] = "帮派徽记 " + this.lMoney;
                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品兑换成功");
                            break;
                        case 4:
                        case 5:
                        case 6:
                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品兑换成功!");
                            break;
                    }
                } //                else if (GameBean.BY_TYPE == 4
                //                        || GameBean.BY_TYPE == 5
                //                        || GameBean.BY_TYPE == 6) {
                //                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品兑换成功!");
                //                }
                else {
                    // MainLogic.getInstance().uiPackage.lMoney += MainLogic.getInstance().uiPackage.getCurrentPackage().getGoodsPrice(MainLogic.getInstance().uiPackage.shPos) * MainLogic.getInstance().uiPackage.getCurrentPackage().getGoodsStackNum(MainLogic.getInstance().uiPackage.shPos);
                    MainLogic.getInstance().uiPackage.getCurrentPackage().deleteGoods(MainLogic.getInstance().uiPackage.shPos);
//                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "道具出售成功");
                }
                break;
            case 2:
                this.lMoney -= this.items.getGoodsPrice(shPos);
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的背背包已满，物品已经放入临时物品背包");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的背包空间不够!");
                break;
            case 4:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您没有足够的金钱购买该道具");
                break;
            case 5:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品购买失败");
                break;
            case 6:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "出售物品失败");
                break;
            case 7:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您没有足够的牌子兑换该物品!");
                break;
            case 8:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您没有足够帮派徽记兑换该物品");
                break;
            case 9:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您没有足够的天穹图");
                break;
            case 10:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您没有足够的烛龙头骨残片");
                break;
            case 11:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您没有足够的物品进行兑换");
                break;
            case 12:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的等级不够兑换");
                break;
        }
    }

    /**
     * 验证用户购买东西的金币或是否足够
     * @param byBuyNum
     * @return 
     */
    public void buyStoreGoods(byte byBuyNum) {
        switch (this.byStoreType) {
            case 1:
                if (this.lMoney < this.items.getGoodsPrice(this.shPos) * byBuyNum) {
                    //#if NOKIA_S60V5
                     this.byUiState = 0;
                     MainGame.changeCanvas(MainGame.mainFrame);
                    //#endif
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的龙币数量不足!");
                    return;
                }
                break;
            case 2:
                if (this.iBrand[0] < this.iBrandPrice[this.shPos * 4] * byBuyNum || this.iBrand[1] < this.iBrandPrice[this.shPos * 4 + 1] * byBuyNum || this.iBrand[2] < this.iBrandPrice[this.shPos * 4 + 2] * byBuyNum || this.iBrand[3] < this.iBrandPrice[this.shPos * 4 + 3] * byBuyNum) {
                    //#if NOKIA_S60V5
                     this.byUiState = 0;
                     MainGame.changeCanvas(MainGame.mainFrame);
                    //#endif
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的牌子数量不足!");
                    return;
                }
                break;
            case 3:
                if (this.lMoney < this.items.getGoodsPrice(this.shPos) * byBuyNum) {
                    //#if NOKIA_S60V5
                     this.byUiState = 0;
                     MainGame.changeCanvas(MainGame.mainFrame);
                    //#endif
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的帮派徽记数量不足!");
                    return;
                }
                break;
        }
        this.byBuyGoodsNum = byBuyNum;
        GameBean.b_WAIT_NET_MSG_BACK = true;
        GameBean.STR_CDM_GOODS_KEY = this.items.getGoodsKey(this.shPos);
        GameBean.BY_TYPE = 1;
        GameBean.BY_OP_TYPE = this.byStoreType;
        GameBean.BY_GOODS_NUM = byBuyNum;
        GameBean.L_NPC_ID = this.lNpcID;
        //#if NOKIA_S60V5
         this.byUiState = 0;
         MainGame.changeCanvas(MainGame.mainFrame);
        //#endif
        MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_STORE, Constant.SOCKET_MSG_TYPE_LOGIC);
    }

    /**
     * 初始化NPC出售物品界面
     */
    public void initStoreBuy() {
        /*****************************/
//        byStoreType = 1;
//        this.items = new Goods((short) 30, Constant.ITEM_COLUMN_TYPE_COMMON);
//        this.items.addGoods((short) 0, true, -1, (short) -1, "下坡", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 1, true, -1, (short) -1, "下坡2", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 2, true, -1, (short) -1, "下坡3", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 3, true, -1, (short) -1, "下坡4", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.sShopTitle = "买东西";
        /***********************************/
        bySelectIndex = 1;
        this.byState = 0;
        this.shPos = 0;
        bLock = false;
        this.bWaitMSGBack = false;

        switch (this.byStoreType) {
            case 1:
                this.sArray = new String[]{"购买道具", "售价：", "查看物品", "请输入购买数量:", "等级:"};
                this.sOpArray = new String[]{"购买", "查看"};
                break;
            case 2:
                this.sArray = new String[]{"牌子兑换", "兑换：", "查看物品", "请输入兑换数量:", "龙睛 " + this.iBrand[0] + "追星 " + this.iBrand[1] + "|凤瞳 " + this.iBrand[2] + "七杀 " + this.iBrand[3], "龙睛", "追星", "凤瞳", "七杀", "等级:"};
                this.sOpArray = new String[]{"兑换", "查看"};
                break;
            case 3:
                this.sArray = new String[]{"帮派徽记兑换", "兑换：", "查看物品", "请输入兑换数量:", "帮派徽记 " + this.lMoney, "帮派徽记 ", "等级:"};
                this.sOpArray = new String[]{"兑换", "查看"};
                break;
        }
        this.sButton = new String[]{"确定", "取消", ""};//(0键快速翻页)
        this.byTotalPage = (byte) Tools.ceil(this.items.getMaxColumNum(), 28);
        this.byCurrentPage = 1;
        this.byBuyGoodsNum = 1;
        this.byMenuIndex = 0;
        this.setGoodsState(this.items, (short) 0);
        //界面中的位置的统一配置
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 46;
         iPositionY = Constant.UI_START_Y + 124;
         sButton = new String[]{"确认", "取消", ""};//(0键快速翻页)
        //#elif NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 25;
//#         iPositionY = this.iStartPointY + 64;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 29;
//#        iPositionY = this.iStartPointY + 64;
        //#endif
        try {
            //#if NOKIA_S60V5
             imgArray = new Image[14];
             this.imgArray[0] = ResManager.createImage(90000041);  //箭头图片
             this.imgArray[1] = Tools.makeBlueMask();   //蓝色光片
             this.imgArray[2] = ResManager.createImage(90000017); //背景图片
             this.imgArray[3] = ResManager.createImage(90000044);//确定取消图片
             this.imgArray[4] = Tools.makeTransparent(Constant.DRAW_WIDTH, 10, 180, 0x000000);//遮罩层
             this.imgArray[5] = ResManager.createImage(90000060, Constant.RES_PUBLIC_TEMP, Constant.RES_UI_PATH, false, 255);//文字图片
             this.imgArray[6] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角图片tishi.png
             this.imgArray[7] = ResManager.createImage(90000042);//金钱图片
             this.imgArray[8] = ResManager.createImage(90000063);//查看元宝文字图片,龙币图片
             this.imgArray[9] = ResManager.createImage(90000047);//大数字
             this.imgArray[10] = ResManager.createImage(90000084);//方向键
             this.imgArray[11] = ResManager.createImage(90000085);//确认
             this.imgArray[12] = ResManager.createImage(90000086);//蓝条
             this.imgArray[13] = ResManager.createImage(90000043);//文字图片
            //#else
//#            imgArray = new Image[10];
//#            this.imgArray[0] = ResManager.createImage(90000041);  //箭头图片
//#            this.imgArray[1] = Tools.makeBlueMask();   //蓝色光片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[2] = ResManager.createImage(90000017);
//# //            imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            this.imgArray[2] = ResManager.createImage(90000017); //背景图片
            //#endif
//#            this.imgArray[3] = ResManager.createImage(90000044);//确定取消图片
//#            this.imgArray[4] = Tools.makeTransparent(Constant.DRAW_WIDTH, 10, 180, 0x000000);//遮罩层
//#//            this.imgArray[5] = ResManager.createImage(90000043);//文字图片
//#            this.imgArray[6] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角图片tishi.png
//#            this.imgArray[7] = ResManager.createImage(90000042);//金钱图片
//#            this.imgArray[8] = ResManager.createImage(90000063);//查看元宝文字图片,龙币图片
//#            this.imgArray[9] = ResManager.createImage(90000047);//大数字
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
    }

    /**
     * 更新npc出售物品界面逻辑
     */
    public void updateStoreBuy() {
        switch (this.byUiState) {
            case 0:
                if (!GameBean.b_WAIT_NET_MSG_BACK) {
                    if (!bKeypressLock) {
                        if (!bLock) {
                            if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                if (this.bySelectIndex > 1) {
                                    this.bySelectIndex -= 1;
                                    this.shPos = (short) (this.bySelectIndex == 4 ? (this.byCurrentPage - 1) * 28 + 21 : this.shPos - 7);
                                    this.setGoodsState(this.items, this.shPos);
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                if (this.bySelectIndex < 5) {
                                    this.bySelectIndex += 1;
                                    this.shPos = (short) (this.bySelectIndex == 5 ? -1 : this.shPos + 7);
                                    this.setGoodsState(this.items, this.shPos);
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                                if (this.bySelectIndex >= 1 && this.bySelectIndex <= 4) {
                                    this.shPos = (short) (this.shPos == (this.byCurrentPage - 1) * 28 ? (this.byCurrentPage - 1) * 28 : this.shPos - 1);
                                    this.bySelectIndex = (byte) ((this.shPos - (this.byCurrentPage - 1) * 28) / 7 + 1);
                                    this.setGoodsState(this.items, this.shPos);
                                } else if (this.bySelectIndex == 5) {
                                    if (this.byCurrentPage > 1) {
                                        this.byCurrentPage = (byte) (this.byCurrentPage - 1);
                                    }
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                                if (this.bySelectIndex >= 1 && this.bySelectIndex <= 4) {
                                    this.shPos = (short) (this.shPos == this.byCurrentPage * 28 ? this.byCurrentPage * 28 : this.shPos + 1);
                                    this.bySelectIndex = (byte) ((this.shPos - (this.byCurrentPage - 1) * 28) / 7 + 1);
                                    this.setGoodsState(this.items, this.shPos);
                                } else if (this.bySelectIndex == 5) {
                                    if (this.byCurrentPage < this.byTotalPage) {
                                        this.byCurrentPage = (byte) (this.byCurrentPage + 1);
                                    }
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_0, false)) {
                                this.bySelectIndex = 5;
                                this.byCurrentPage = (byte) (this.byCurrentPage == this.byTotalPage ? 1 : this.byCurrentPage + 1);
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                                if (this.shPos < this.items.getMaxColumNum() && this.items.checkColumnHasGoods(this.shPos)) {
                                    this.bLock = true;
                                    this.byMenuIndex = 0;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, false);
                            } else {
                                getGoodsDescFromNet();
                            }
                        } else {
                            if (this.bySelectIndex >= 5) {
                                this.bLock = false;
                                return;
                            } else {
                                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                    this.bLock = false;
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                    this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 0);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                    this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 1);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                                    this.bLock = false;
                                    if (this.byMenuIndex == 0) {
                                        //#if NOKIA_S60V5
                                         MainLogic.getInstance().inputInterFace.setInputInterFace((byte) 1, "请输入要购买的物品数量:");
                                         MainLogic.getInstance().inputInterFace.commonInput.setString(String.valueOf(this.byBuyGoodsNum));
                                         MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
                                        //#else
//#                                        this.byUiState = 2;
//#                                        this.byBuyGoodsNum = 1;
                                        //#endif
                                    } else if (this.byMenuIndex == 1) {
                                        MainLogic.getInstance().uiInterFace.sysMessage.checkStoreItem(this.items.getGoodsAlias(this.shPos), this.items.getGoodsColor(shPos), this.items.icon[this.shPos], this.items.getGoodsKey(this.shPos));
                                    }
                                }
                            }
                        }
                    } else {
                        if (this.byState == 1 || this.byState == 2) {
                            iPositionY = Tools.updateLinePos(this.iArray, iPositionY);
                            if (this.iArray == null || this.iArray[1] == 0) {
                                this.byState = 0;
                                this.bKeypressLock = false;
                            }
                        }
                        MainCanvas.clearInput();
                    }

                }
                break;
            case 2:
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                    this.byUiState = 0;
                    if (this.byBuyGoodsNum < 1 || this.byBuyGoodsNum > 99) {
                        this.byBuyGoodsNum = 1;
                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您输入的数量不正确!");
                    } else {
                        this.buyStoreGoods(byBuyGoodsNum);
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                    this.byUiState = 0;
                    this.byBuyGoodsNum = 1;
                } else {
                    this.byBuyGoodsNum = (byte) Tools.updateInputCanvas(this.byBuyGoodsNum, 99);
                }
                this.bFlag = this.bFlag ? false : true;
                break;
        }
        MainCanvas.clearInput();
    }
    /**
     * 绘制npc出售界面
     * @param g 
     */
    public String sGoodsPrice;//牌子价格显示
    public String[] sButton;//
    /*
     * 购买兑换物品界面绘制
     */

    public void drawStoreBuy(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[10], this.imgArray[11], this.imgArray[12], this.imgArray[13], this.sArray[0]);
         iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1);
         iStartY = this.iStartPointY;
         //左面的
         Tools.drawTilePic(g, (byte) 2, iStartX, iStartY + 34, 250 - 34 - 13, this.imgArray[6], 14, 0, 13, 13, Constant.TRANS_NONE);
         //右面的
         Tools.drawTilePic(g, (byte) 2, iStartX + 318 - 13, iStartY + 35, 250 - 34 - 13, this.imgArray[6], 14, 0, 13, 13, Constant.TRANS_ROT180);
         //下面的
         Tools.drawTilePic(g, (byte) 1, iStartX + 13, iStartY + 250 - 13, 318 - 26, this.imgArray[6], 14, 14, 13, 13, Constant.TRANS_NONE);//下面
         //底部
         g.drawRegion(this.imgArray[6], 0, 14, 13, 13, Constant.TRANS_NONE, iStartX, iStartY + 250 - 13, 0); //左下角
         g.drawRegion(this.imgArray[6], 0, 14, 13, 13, Constant.TRANS_ROT270, iStartX + 318 - 13, iStartY + 250 - 13, 0); //右下角
         //填充中间的部分呢
         g.setColor(0x9c9c9c);
         g.fillRect(iStartX + 13, iStartY + 34, 292, 204);
 
         g.setColor(0x9c9c9c);
         g.fillRect(iStartX + 13, iStartY + 13, 150 - 26, 34 - 13);
         g.drawRegion(this.imgArray[6], 0, 0, 13, 13, Constant.TRANS_NONE, iStartX, iStartY, 0); //左上角
         g.drawRegion(this.imgArray[6], 0, 0, 13, 13, Constant.TRANS_ROT90, iStartX + 150 - 13, iStartY, 0); //右上角
         Tools.drawTilePic(g, (byte) 2, iStartX, iStartY + 13, 34 - 13, this.imgArray[6], 14, 0, 13, 13, Constant.TRANS_NONE);//左面
         Tools.drawTilePic(g, (byte) 2, iStartX + 150 - 13, iStartY + 13, 34 - 13, this.imgArray[6], 14, 0, 13, 13, Constant.TRANS_ROT180);//右面
         Tools.drawTilePic(g, (byte) 1, iStartX + 13, iStartY, 150 - 26, this.imgArray[6], 28, 0, 13, 13, Constant.TRANS_NONE);//上面
         Tools.drawTilePic(g, (byte) 1, iStartX + 150, iStartY + 34, 310 - 142, this.imgArray[6], 28, 0, 13, 13, Constant.TRANS_NONE);//上面
         //tab标题背景
         g.drawRegion(this.imgArray[6], 42, 0, 10, 24, Constant.TRANS_NONE, iStartX + 6, iStartY + 5, 0); //头
         g.drawRegion(this.imgArray[6], 42, 0, 10, 24, Constant.TRANS_ROT180, iStartX + 150 - 16, iStartY + 5, 0); //尾
         Tools.drawTilePic(g, (byte) 1, iStartX + 16, iStartY + 5, 150 - 32, this.imgArray[6], 53, 0, 10, 24, Constant.TRANS_NONE);//中间
         //绘制标题
         Tools.drawShadowString(g, (byte) 1, this.sShopTitle, iStartX + ((150 - Constant.FONT_SMALL.stringWidth(this.sShopTitle)) >> 1), iStartY + ((34 - Constant.FONT_SMALL_HEIGHT) >> 1), 0x00ccff, 0x000000);
         //绘制物品
         iStartY = this.iStartPointY + 38;
         iStartX = iStartX + 6;
         Tools.drawPackageBox(g, items, this.imgArray[9], this.imgArray[0], sButton[2], iStartX, iStartY, this.byCurrentPage, this.byTotalPage, null, null);
         //显示物品的名称和堆叠数量
         Tools.setColor(g, 0xFFFFFF);
         switch (this.byStoreType) {
             case 1:
                 //显示玩家的游戏币
                 Tools.drawMoney(g, lMoney, this.imgArray[8], this.imgArray[7], this.imgArray[9], Constant.UI_START_X + 30, Constant.UI_START_Y + 382);
                 break;
             case 2:
                 //玩家身上牌子数量
                 Tools.drawParagraph(g, Constant.UI_START_X + 30, Constant.UI_START_Y + 382, 340, this.sArray[4], 0xFFFFFF, Constant.FONT_SMALL_HEIGHT, -1);
                 break;
             case 3:
                 //显示玩家身上帮派徽记数量
                 g.drawString(this.sArray[4], Constant.UI_START_X + 30, Constant.UI_START_Y + 382, 0);
                 break;
         }
         //绘制选中横条
         if (this.bySelectIndex == 5) {
             Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 38 + 193 + Constant.FONT_SMALL_HEIGHT, Constant.DRAW_WIDTH);
         }
         //绘制物品的选中状态(最上层。防止被覆盖)
         if (this.bySelectIndex >= 1 && this.bySelectIndex <= 4) {
             if (this.shPos >= 0) {
                 if (this.shPos % 7 == 0) {
                     this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1) + 6;
                     iStartY = this.iStartPointY + 38 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 44;
                 } else {
                     this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1) + 6 + (this.shPos % 7) * 44;
                     iStartY = this.iStartPointY + 38 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 44;
                 }
                 this.items.drawSelectStyle(g, iStartX, iStartY);
                 if (this.items.checkColumnHasGoods(shPos)) {
 
                     Tools.drawHCycleRollingParagraph(g, this.items.getGoodsDesc(this.shPos), this.iGoodsDescHeight, 300, 72, Constant.FONT_SMALL_HEIGHT, Constant.UI_START_X + 30, Constant.UI_START_X + 305, 0xFFFFFF, -1);
                     if (bLock) {
                         Goods.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, iStartX, iStartY);
                     } else {
                         Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
                     }
                     Tools.drawShadowString(g, (byte) 1, this.sGoodsPrice, Constant.UI_START_X + 340 - Constant.FONT_SMALL.stringWidth(this.sGoodsPrice), this.iStartPointY + 33 - Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x000000);
                 }
             }
         }
        //#else
//#
//#
//#
//#
//#
        //#if NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[2], sButton[0], sButton[1], this.sArray[0]);
        //#else
//#        Tools.drawFrame(g, this.imgArray[2], this.imgArray[1], sButton[0], sButton[1], this.sArray[0]);
        //#endif
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1);
//#        iStartY = this.iStartPointY;
//#        //出售物品背景
//#
//#        g.drawRegion(
//#                this.imgArray[6], 0, 0, 7, 7, Constant.TRANS_NONE, iStartX, iStartY, 0); //左上角
//#        g.drawRegion(
//#                this.imgArray[6], 7, 0, 7, 7, Constant.TRANS_NONE, iStartX + 100 - 7, iStartY, 0); //右上角
//#        g.drawRegion(
//#                this.imgArray[6], 0, 7, 7, 7, Constant.TRANS_NONE, iStartX, iStartY + 182, 0); //左下角
//#        g.drawRegion(
//#                this.imgArray[6], 7, 7, 7, 7, Constant.TRANS_NONE, iStartX + 232 - 7, iStartY + 182, 0); //右下角
//#        //绘制四周的边框
//#        //上面的边框
//#        Tools.drawTilePic(g, (byte) 1, iStartX + 7, iStartY, 86, this.imgArray[6], 21, 0, 6, 7, Constant.TRANS_NONE);
//#        Tools.drawTilePic(g, (byte) 1, iStartX + 100, iStartY + 29, 131, this.imgArray[6], 21, 0, 6, 7, Constant.TRANS_NONE);
//#        //下面
//#        Tools.drawTilePic(g, (byte) 1, iStartX + 7, iStartY + 182, 218, this.imgArray[6], 21, 7, 6, 7, Constant.TRANS_NONE);
//#        //左面
//#        Tools.drawTilePic(g, (byte) 2, iStartX, iStartY + 7, 175, this.imgArray[6], 14, 0, 7, 7, Constant.TRANS_NONE);
//#        //右面
//#        Tools.drawTilePic(g, (byte) 2, iStartX + 93, iStartY + 7, 22, this.imgArray[6], 14, 7, 7, 7, Constant.TRANS_NONE);
//#        Tools.drawTilePic(g, (byte) 2, iStartX + 225, iStartY + 30, 154, this.imgArray[6], 14, 7, 7, 7, Constant.TRANS_NONE);
//#        Tools.setColor(g, 0x989898);
//#        g.fillRect(iStartX + 7, iStartY + 7, 93, 29);
//#        g.fillRect(iStartX + 82 - 7, iStartY + 29, 7, 7);
//#        g.fillRect(iStartX + 7, iStartY + 36, 218, 146);
//#        g.drawRegion(this.imgArray[6], 27, 0, 5, 14, Constant.TRANS_NONE, iStartX + 3, iStartY + 7, 0); //头
//#        g.drawRegion(this.imgArray[6], 27, 0, 5, 14, Constant.TRANS_ROT180, iStartX + 100 - 3 - 5, iStartY + 7, 0); //尾
//#        Tools.drawTilePic(g, (byte) 1, iStartX + 3 + 5, iStartY + 7, 84, this.imgArray[6], 31, 0, 1, 14, Constant.TRANS_NONE);
//#        //绘制标题
//#        Tools.drawShadowString(g, (byte) 1, this.sShopTitle, iStartX + ((100 - Constant.FONT_SMALL.stringWidth(this.sShopTitle)) >> 1), iStartY + ((28 - Constant.FONT_SMALL_HEIGHT) >> 1), 0x00ccff, 0x000000);
//#        //绘制物品
//#        Tools.drawPackageBox(g, items, this.imgArray[9], this.imgArray[0], sButton[2], iStartX + 4, iStartY + 36, this.byCurrentPage, this.byTotalPage, null, null);
//#        //显示物品的名称和堆叠数量
//#        Tools.setColor(g, 0xFFFFFF);
        //#if NOKIA_E72
//#         switch (this.byStoreType) {
//#             case 1:
//#                 //显示玩家的游戏币
//#                 Tools.drawMoney(g, lMoney, this.imgArray[8], this.imgArray[7], this.imgArray[9], iStartX + 7, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 14);
//#                 break;
//#             case 2:
//#                 //玩家身上牌子数量
//#                 g.drawString(this.sArray[4], iStartX + 7, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 2 - Constant.FONT_SMALL_HEIGHT, 0);
//#                 break;
//#             case 3:
//#                 //显示玩家身上帮派徽记数量
//#                 g.drawString(this.sArray[4], iStartX + 7, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 2 - Constant.FONT_SMALL_HEIGHT, 0);
//#                 break;
//#         }
        //#else
//#
//#
//#        switch (this.byStoreType) {
//#            case 1:
//#                //显示玩家的游戏币
//#                Tools.drawMoney(g, lMoney, this.imgArray[8], this.imgArray[7], this.imgArray[9], iStartX + 7, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 24 - Constant.FONT_SMALL_HEIGHT);
//#                break;
//#            case 2:
//#                //玩家身上牌子数量
//#                g.drawString(this.sArray[4], iStartX + 7, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 24 - Constant.FONT_SMALL_HEIGHT, 0);
//#                break;
//#            case 3:
//#                //显示玩家身上帮派徽记数量
//#                g.drawString(this.sArray[4], iStartX + 7, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 24 - Constant.FONT_SMALL_HEIGHT, 0);
//#                break;
//#        }
        //#endif
//#        //绘制选中横条
//#
//#
//#        if (this.bySelectIndex == 5) {
//#            Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 36 + 128 + Constant.FONT_SMALL_HEIGHT, Constant.DRAW_WIDTH);
//#        }
//#        //绘制物品的选中状态(最上层。防止被覆盖)
//#
//#        if (this.bySelectIndex >= 1 && this.bySelectIndex <= 4) {
//#            if (this.shPos >= 0) {
//#                if (this.shPos % 7 == 0) {
//#                    this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 4;
//#                    iStartY = this.iStartPointY + 36 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 32;
//#                } else {
//#                    this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 4 + +(this.shPos % 7) * 32;
//#                    iStartY = this.iStartPointY + 36 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 32;
//#                }
//#                this.items.drawSelectStyle(g, iStartX, iStartY);
//#                if (this.items.checkColumnHasGoods(shPos)) {
                    //#if NOKIA_E72
                    //#else
//#                    Tools.drawHCycleRollingParagraph(g, this.items.getGoodsDesc(this.shPos), this.iGoodsDescHeight, 209, 49, 16, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 229) >> 1) + 10, this.iStartPointY + 190, 0xFFFFFF, -1);
                    //#endif
//#                    if (bLock) {
//#                        Goods.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, iStartX, iStartY);
//#                    } else {
//#                        Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
//#                    }
//#                    Tools.drawShadowString(g, (byte) 1, this.sGoodsPrice, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 232 - Constant.FONT_SMALL.stringWidth(this.sGoodsPrice), this.iStartPointY + 28 - Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x000000);
//#                }
//#            }
//#        }
//#
//#        if (this.byUiState == 2) {
//#            Tools.drawInputCanvas(g, this.imgArray[4], (byte) 2, 232, 65, this.imgArray[6], this.imgArray[3], 0, 0, 22, 10, this.imgArray[3], 22, 0, 21, 10, 0x989898, this.sArray[3], 65, 18, this.byBuyGoodsNum, this.bFlag, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_WIDTH - 65) >> 1));
//#        }
        //#endif
         
         
         if(bLock)
        	 MainView.drawTouchRect(g, mPackageOperateRect);
         else
         {
              MainView.drawTouchRect(g, mPackagePageTouchRect);
              MainView.drawTouchRect(g, mPackageTouchRect);
         }
    }

    /**
     * 生成牌子价格字符串
     * @return 
     */
    private void makeGoodsPrice() {
        this.sGoodsPrice = "";
        switch (this.byStoreType) {
            case 1:
                this.sGoodsPrice = this.sArray[1] + Tools.moneyConvert(this.items.getGoodsPrice(shPos));
                break;
            case 2:
                if (this.iBrandPrice[this.shPos * 4] > 0) {
                    this.sGoodsPrice += this.sArray[5] + this.iBrandPrice[this.shPos * 4] + "  ";
                }
                if (this.iBrandPrice[this.shPos * 4 + 1] > 0) {
                    this.sGoodsPrice += this.sArray[6] + this.iBrandPrice[this.shPos * 4 + 1] + "  ";
                    ;
                }
                if (this.iBrandPrice[this.shPos * 4 + 2] > 0) {
                    this.sGoodsPrice += this.sArray[7] + this.iBrandPrice[this.shPos * 4 + 2] + "  ";
                    ;
                }
                if (this.iBrandPrice[this.shPos * 4 + 3] > 0) {
                    this.sGoodsPrice += this.sArray[8] + this.iBrandPrice[this.shPos * 4 + 3];
                }
                break;
            case 3:
                this.sGoodsPrice = this.sArray[5] + this.items.getGoodsPrice(shPos);
                break;
        }
    }

    /**************************出售物品界面***************************************************************************/
    /**
     * 初始化物玩家出售物品界面
     */
    public void initStoreSold() {
        //Tools.printLog("初始化更新物品");
        MainLogic.getInstance().uiPackage.bSoldItems = true;
        MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
    }

    /**
     * 在通用的包裹界面更新玩家出售逻辑
     */
    public void updateStoreSold() {
        //Tools.printLog("更新出售物品");
    }

    public void drawStoreSold(Graphics g) {
        //Tools.printLog("绘制出售物品");
    }

    /**************************交易物品界面***************************************************************************/
    public void openTrade() {
        MainLogic.getInstance().pushState(Constant.GAME_UI_TRADE, true);
        this.lTraderID = GameBean.L_PLAYER_ID;
        this.sTrader = GameBean.STR_CMD_PLAYER_NICK;
        GameBean.STR_CMD_PLAYER_NICK = null;
        this.lPlayerMoney = GameBean.I_MONEY;
    }

    /**
     * 初始化玩家间交易界面资源
     */
    public void initTrade() {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        this.shPos = 0;
        bTradeLock = new boolean[]{false, false};
//        bTradeLock = new boolean[]{true, true};

        this.byState = 0;
        this.lMoney = 0L;
        this.lTradeMoney = 0L;
        bLock = false;
        this.bWaitMSGBack = false;
        this.sArray = new String[]{"交易", "确定交易", "锁定", "取消交易", "确定", "取消"};
        this.sOpArray = new String[]{"查看", "购买"};
        this.byTotalPage = 1;
        this.byCurrentPage = 1;
        this.items = new Goods((short) 14, Constant.ITEM_COLUMN_TYPE_COMMON);
        this.myItems = new Goods((short) 14, Constant.ITEM_COLUMN_TYPE_COMMON);
        this.byPopUpState = 1;
        this.byButtonSelectIndex = 2;
        this.shSelectIndex = new short[14];
        for (short i = 0; i < 14; i++) {
            this.shSelectIndex[i] = -1;
        }
        bySelectIndex = 3;
        bySubSelectIndex = 1;
        this.byMenuIndex = 0;
        //#if NOKIA_S60V5
         iPositionY = Constant.UI_START_Y + 299;
        //#else
        //#if NOKIA_E72
//#         Tools.initE72ScollBar();
//#         Tools.updateE72ScollBar(-30);
        //#endif
//#        iPositionY = Constant.UI_START_Y + 212 + UiInterFace.iScreenOffsetH;
        //#endif
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[13];
             this.imgArray[0] = ResManager.createImage(90000041);//箭头图片
             this.imgArray[1] = Tools.makeBlueMask();//蓝色光片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
            //#else
             this.imgArray[2] = ResManager.createImage(90000017);//背景图片
            //#endif
             this.imgArray[3] = ResManager.createImage(90000034);//锁定图标
             this.imgArray[4] = ResManager.createImage(90000047); //大数字
             this.imgArray[5] = ResManager.createImage(90000060, Constant.RES_PUBLIC_TEMP, Constant.RES_UI_PATH, false, 255); //文字图片
             this.imgArray[6] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角图片
             this.imgArray[7] = ResManager.createImage(90000042);//金银铜图片
             this.imgArray[8] = ResManager.createImage(90000063);//龙币，金银铜文字图片
             this.imgArray[9] = ResManager.createImage(90000043);//文字
             this.imgArray[10] = ResManager.createImage(90000084);//方向键
             this.imgArray[11] = ResManager.createImage(90000085);//确认
             this.imgArray[12] = ResManager.createImage(90000086);//蓝条
            //#else
//#            imgArray = new Image[9];
//#            this.imgArray[0] = ResManager.createImage(90000041);//箭头图片
//#            this.imgArray[1] = Tools.makeBlueMask();//蓝色光片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[2] = ResManager.createImage(90000017);
//# //            imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            this.imgArray[2] = ResManager.createImage(90000017);//背景图片
            //#endif
//#            this.imgArray[3] = ResManager.createImage(90000034);//锁定图标
//#            this.imgArray[4] = ResManager.createImage(90000047); //大数字
//#            this.imgArray[5] = ResManager.createImage(90000060, Constant.RES_PUBLIC_TEMP, Constant.RES_UI_PATH, false, 255); //文字图片
//#            this.imgArray[6] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角图片
//#            this.imgArray[7] = ResManager.createImage(90000042);//金银铜图片
//#            this.imgArray[8] = ResManager.createImage(90000063);//龙币，金银铜文字图片
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }

    }

    /**
     * 添加交易物品
     * byType
     * */
    public void addTraderItem(byte byType, long lColumnKey, String sGoodsName, int iIconID, short shGoodsType, short shStackNum, byte byDurability, byte byColor) {
        if (byType == 1) {//同步添加自己交易的物品
            for (byte i = 0; i < 14; i++) {
                if (!this.myItems.checkColumnHasGoods((short) i)) {
                    MainLogic.getInstance().uiPackage.clonePackageGoods(this.myItems, (short) i);
                    this.setTradePackageAlreadySelected((short) i, (byte) 1, (byte) (MainLogic.getInstance().uiPackage.byTabIndex - 1), MainLogic.getInstance().uiPackage.shPos);
                    this.makeItemsTips(myItems, (short) (this.bySubSelectIndex - 1), null, null);
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品添加成功!");
                    break;
                }
            }
        } else {//添加别人交易的物品
            byte index = 0;
            for (byte i = 0; i < 14; i++) {
                if (!this.items.checkColumnHasGoods(i)) {
                    index = i;
                    break;
                }
            }
            this.items.addGoods((short) index, true, lColumnKey, shGoodsType, sGoodsName, shStackNum, iIconID, (byte) -1, byColor, (byte) -1, (byte) -1, (byte) -1, null, (short) -1, -1, byDurability, null);
            if ((this.bySelectIndex == 1 || this.bySelectIndex == 2) && index == this.bySubSelectIndex - 1) {
                this.makeItemsTips(items, (short) (this.bySubSelectIndex - 1), null, null);
            }
        }
    }

    /**
     * 删除交易物品
     */
    public void delTraderItem(byte byType, long lColumnKey) {
        if (byType == 1) {//删除自己交易的物品
            this.myItems.deleteGoods((short) (this.bySubSelectIndex - 1));
            this.setTradePackageAlreadySelected((short) (this.bySubSelectIndex - 1), (byte) 0, (byte) -1, (short) -1);
        } else {//删除别人交易的物品
            for (byte i = 0; i < 14; i++) {
                if (this.items.checkColumnHasGoods(i) && lColumnKey == this.items.getGoodsColumnKey(i)) {
                    MainLogic.getInstance().uiInterFace.store.items.deleteGoods(i);
                    break;
                }
            }
        }
    }

    /**
     * 更新交易逻辑
     */
    public void updateTrade() {
        switch (this.byUiState) {
            case 0:
                if (!GameBean.b_WAIT_NET_MSG_BACK) {
                    if (!bKeypressLock) {
                        if (!bLock) {
                            if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                if (this.bySelectIndex > 1) {
                                    this.bySelectIndex -= 1;

                                    switch (this.bySelectIndex) {
                                        case 1:
                                            this.bySubSelectIndex -= 7;

                                            //#if NOKIA_E72
//#                                             Tools.updateE72ScollBar(0);
                                            //#endif
                                            break;
                                        case 2:
                                            this.bySubSelectIndex += 7;

                                            //#if NOKIA_E72
//#                                             Tools.updateE72ScollBar(-10);
                                            //#endif
                                            break;
                                        case 3:
                                            this.bySubSelectIndex -= 7;

                                            //#if NOKIA_E72
//#                                             Tools.updateE72ScollBar(-30);
                                            //#endif
                                            break;
                                        case 4:
                                            this.bySubSelectIndex = 8;

                                            //#if NOKIA_E72
//#                                             Tools.updateE72ScollBar(-50);
                                            //#endif
                                            break;
                                        case 5:
                                            //#if NOKIA_E72
//#                                             Tools.updateE72ScollBar(-70);
                                            //#endif
                                            this.bySubSelectIndex = -1;
                                            this.iPositionY = Constant.UI_START_Y + 343 + Constant.FONT_SMALL_HEIGHT;
                                            break;
                                    }
                                    if ((this.bySelectIndex == 3 || this.bySelectIndex == 4) && this.myItems.checkColumnHasGoods((short) (this.bySubSelectIndex - 1))) {
                                        this.makeItemsTips(myItems, (short) (this.bySubSelectIndex - 1), null, null);
                                    } else if ((this.bySelectIndex == 1 || this.bySelectIndex == 2) && this.items.checkColumnHasGoods((short) (this.bySubSelectIndex - 1))) {
                                        this.makeItemsTips(items, (short) (this.bySubSelectIndex - 1), null, null);
                                    }
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                if (this.bySelectIndex < 6) {
                                    this.bySelectIndex += 1;
                                    switch (this.bySelectIndex) {
                                        case 2:
                                            this.bySubSelectIndex += 7;
                                            //#if NOKIA_E72
//#                                             Tools.updateE72ScollBar(-10);
                                            //#endif
                                            break;
                                        case 3:
                                            this.bySubSelectIndex -= 7;
                                            this.bySubSelectIndex = 1;
                                            //#if NOKIA_E72
//#                                             Tools.updateE72ScollBar(-30);
                                            //#endif
                                            break;
                                        case 4:
                                            this.bySubSelectIndex += 7;
                                            //#if NOKIA_E72
//#                                             Tools.updateE72ScollBar(-50);
                                            //#endif
                                            break;
                                        case 5:
                                            this.bySubSelectIndex += 1;
                                            this.iPositionY = Constant.UI_START_Y + 343 + Constant.FONT_SMALL_HEIGHT;
                                            //#if NOKIA_E72
//#                                             Tools.updateE72ScollBar(-70);
                                            //#endif
                                            break;
                                        case 6:
                                            this.bySubSelectIndex += 1;
                                            this.iPositionY = Constant.UI_START_Y + 382 + Constant.FONT_SMALL_HEIGHT;
                                            //#if NOKIA_E72
//#                                             Tools.updateE72ScollBar(-80);
                                            //#endif
                                            break;
                                    }

                                    if ((this.bySelectIndex == 3 || this.bySelectIndex == 4) && this.myItems.checkColumnHasGoods((short) (this.bySubSelectIndex - 1))) {
                                        this.makeItemsTips(myItems, (short) (this.bySubSelectIndex - 1), null, null);
                                    } else if ((this.bySelectIndex == 1 || this.bySelectIndex == 2) && this.items.checkColumnHasGoods((short) (this.bySubSelectIndex - 1))) {
                                        this.makeItemsTips(items, (short) (this.bySubSelectIndex - 1), null, null);
                                    }
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                    case 2:
                                        this.bySubSelectIndex = (byte) (this.bySubSelectIndex > 1 ? this.bySubSelectIndex - 1 : 1);
                                        this.bySelectIndex = (byte) (this.bySubSelectIndex > 7 ? 2 : 1);
                                        if (this.items.checkColumnHasGoods((short) (this.bySubSelectIndex - 1))) {
                                            this.makeItemsTips(items, (short) (this.bySubSelectIndex - 1), null, null);
                                        }
                                        break;
                                    case 3:
                                    case 4:
                                        this.bySubSelectIndex = (byte) (this.bySubSelectIndex > 1 ? this.bySubSelectIndex - 1 : 1);
                                        this.bySelectIndex = (byte) (this.bySubSelectIndex > 7 ? 4 : 3);
                                        if (this.items.checkColumnHasGoods((short) (this.bySubSelectIndex - 1))) {
                                            this.makeItemsTips(items, (short) (this.bySubSelectIndex - 1), null, null);
                                        }
                                        break;
                                    case 6:
                                        this.byButtonSelectIndex = (byte) (this.byButtonSelectIndex > 1 ? this.byButtonSelectIndex - 1 : 3);
                                        break;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                    case 2:
                                        this.bySubSelectIndex = (byte) (this.bySubSelectIndex < 14 ? this.bySubSelectIndex + 1 : 14);
                                        this.bySelectIndex = (byte) (this.bySubSelectIndex > 7 ? 2 : 1);
                                        if (this.items.checkColumnHasGoods((short) (this.bySubSelectIndex - 1))) {
                                            this.makeItemsTips(items, (short) (this.bySubSelectIndex - 1), null, null);
                                        }
                                        break;
                                    case 3:
                                    case 4:
                                        this.bySubSelectIndex = (byte) (this.bySubSelectIndex < 14 ? this.bySubSelectIndex + 1 : 14);
                                        this.bySelectIndex = (byte) (this.bySubSelectIndex > 7 ? 4 : 3);
                                        if (this.myItems.checkColumnHasGoods((short) (this.bySubSelectIndex - 1))) {
                                            this.makeItemsTips(myItems, (short) (this.bySubSelectIndex - 1), null, null);
                                        }
                                        break;
                                    case 6:
                                        this.byButtonSelectIndex = (byte) (this.byButtonSelectIndex < 3 ? this.byButtonSelectIndex + 1 : 1);
                                        break;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                    case 2:
                                        if (this.items.checkColumnHasGoods((short) (this.bySubSelectIndex - 1))) {
                                            this.bLock = true;
                                            this.byMenuIndex = 0;
                                            this.sOpArray = new String[]{"查看"};
                                        }
                                        break;
                                    case 3:
                                    case 4:
                                        if (this.myItems.checkColumnHasGoods((short) (this.bySubSelectIndex - 1))) {
                                            this.bLock = true;
                                            this.byMenuIndex = 0;
                                            if (!this.bTradeLock[1]) {
                                                this.sOpArray = new String[]{"查看", "移除"};
                                            } else {
                                                this.sOpArray = new String[]{"查看"};
                                            }
                                        } else {
                                            if (!this.bTradeLock[1]) {
                                                MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                                            } else {
                                                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您已经锁定，不可以再添加物品!");
                                            }
                                        }
                                        break;
                                    case 5:
                                        if (!this.bTradeLock[1]) {
                                            MainLogic.inputInterFace.setInputInterFace((byte) 0, "请输入您要交易的龙币数量:");
                                            MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
                                        } else {
                                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您已经锁定，不可以再添加交易金钱!");
                                        }
                                        break;
                                    case 6:
                                        if (this.byButtonSelectIndex == 1) {
                                            if (!this.bTradeLock[0] || !this.bTradeLock[1]) {
                                                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "请先锁定或是等待对方锁定");
                                            } else {
                                                GameBean.BY_GOODS_NUM = (byte) this.myItems.getGoodsNum();
                                                if (GameBean.BY_GOODS_NUM > 0) {
                                                    GameBean.L_CMD_GOODS_SLOCKEY_ARRAY = new long[GameBean.BY_GOODS_NUM];
                                                    short j = 0;
                                                    for (byte i = 0; i < 14; i++) {
                                                        if (this.myItems.checkColumnHasGoods(i)) {
                                                            GameBean.L_CMD_GOODS_SLOCKEY_ARRAY[j] = this.myItems.getGoodsColumnKey(i);
                                                            j++;
                                                        }
                                                    }
                                                }
                                                GameBean.b_WAIT_NET_MSG_BACK = true;
                                                GameBean.I_MONEY = (int) this.lMoney;
                                                MainLogic.getInstance().send(Constant.MSG_NET_CMD_TRADE, Constant.SOCKET_MSG_TYPE_LOGIC);

                                            }
                                        } else if (this.byButtonSelectIndex == 2) {
                                            if (this.bTradeLock[1]) {
                                                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "已经锁定,请等待的对方确认!");
                                            } else {
                                                GameBean.b_WAIT_NET_MSG_BACK = true;
                                                GameBean.L_PLAYER_ID = this.lTraderID;
                                                MainLogic.getInstance().send(Constant.MSG_NET_CMD_LOCK_TRADE, Constant.SOCKET_MSG_TYPE_LOGIC);
                                                this.byButtonSelectIndex = 1;
                                            }
                                        } else if (this.byButtonSelectIndex == 3) {
                                            GameBean.L_PLAYER_ID = this.lTraderID;
                                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_TRADE_CANCEL, Constant.SOCKET_MSG_TYPE_LOGIC);
                                            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, false);
                                        }
                                        break;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                GameBean.L_PLAYER_ID = this.lTraderID;
                                MainLogic.getInstance().send(Constant.MSG_NET_CMD_TRADE_CANCEL, Constant.SOCKET_MSG_TYPE_LOGIC);
                                MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, false);
                            }
                        } else {
                            if (this.bySelectIndex < 1 || this.bySelectIndex > 5) {
                                this.bLock = false;
                                return;
                            } else {
                                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                    this.bLock = false;
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                    this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 0);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                    this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 1);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                                    //三级菜单操作
                                    this.bLock = false;
                                    GameBean.b_WAIT_NET_MSG_BACK = true;
                                    if ((this.bySelectIndex == 1 || this.bySelectIndex == 2) && this.byMenuIndex == 0) {
                                        MainLogic.getInstance().uiInterFace.sysMessage.checkItem(this.items.getGoodsAlias((short) (this.bySubSelectIndex - 1)), this.items.getGoodsColor((short) (this.bySubSelectIndex - 1)), this.items.icon[this.bySubSelectIndex - 1], this.lTraderID, this.items.getGoodsColumnKey((short) (this.bySubSelectIndex - 1)));
                                    } else if ((this.bySelectIndex == 3 || this.bySelectIndex == 4) && this.byMenuIndex == 0) {
                                        MainLogic.getInstance().uiInterFace.sysMessage.checkItem(this.myItems.getGoodsAlias((short) (this.bySubSelectIndex - 1)), this.myItems.getGoodsColor((short) (this.bySubSelectIndex - 1)), this.myItems.icon[this.bySubSelectIndex - 1], MainLogic.getInstance().gamePlayer.lPlayerID, this.myItems.getGoodsColumnKey((short) (this.bySubSelectIndex - 1)));
                                    } else if ((this.bySelectIndex == 3 || this.bySelectIndex == 4) && this.byMenuIndex == 1) {
                                        GameBean.L_CMD_GOODS_SLOTKEY = this.myItems.getGoodsColumnKey((short) (this.bySubSelectIndex - 1));
                                        GameBean.BY_OP_TYPE = 2;
                                        GameBean.L_PLAYER_ID = this.lTraderID;
                                        GameBean.BY_TYPE = 1;
                                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_SYNC_TRADE_ITEM, Constant.SOCKET_MSG_TYPE_LOGIC);
                                    }
                                }
                            }
                        }
                    } else {
                        if (this.byState == 1 || this.byState == 2) {
                            iPositionY = Tools.updateLinePos(this.iArray, iPositionY);
                            if (this.iArray == null || this.iArray[1] == 0) {
                                this.byState = 0;
                                this.bKeypressLock = false;
                            }
                        }
                        MainCanvas.clearInput();
                    }
                }
                break;
        }
    }

    /**
     * 绘制玩家交易界面
     * @param g 
     */
    public void drawTrade(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[10], this.imgArray[11], this.imgArray[12], this.imgArray[9], this.sArray[0]);
         //绘制包裹背景
         Tools.drawRoundRect(g, this.imgArray[6], 0x9c9c9c, 318, 156, Constant.UI_START_X + 21, Constant.UI_START_Y + 50);
         //绘制内容
         iStartX = Constant.UI_START_X + 28;
         iStartY = Constant.UI_START_Y + 85;
         for (byte i = 0; i < 14; i++) {
             this.items.drawGoods(g, iStartX, iStartY, i, false, true);
             if (i == 6) {
                 iStartX = Constant.UI_START_X + 28;
                 iStartY = Constant.UI_START_Y + 85 + 44;
             } else {
                 iStartX += 44;
             }
         }
 
         //绘制玩家的的名称
         Tools.drawShadowString(g, (byte) 1, this.sTrader, Constant.UI_START_X + 28, Constant.UI_START_Y + 55, 0xFFFFFF, 0x000000);
         //锁定
         if (!this.bTradeLock[0]) {
             Tools.drawShadowString(g, (byte) 1, this.sArray[2], Constant.UI_START_X + 333 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + 55, 0xFFFFFF, 0x000000);
         } else {
             Tools.drawShadowString(g, (byte) 1, this.sArray[2], Constant.UI_START_X + 333 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + 55, 0xb3b3b3, 0x000000);
             g.drawImage(this.imgArray[3], Constant.UI_START_X + 333 - Constant.FONT_SMALL.stringWidth(this.sArray[2]) + ((Constant.FONT_SMALL.stringWidth(this.sArray[2]) - 15) >> 1), Constant.UI_START_Y + 55, 0);
         }
         //绘制交易的钱数
         Tools.drawMoney(g, this.lTradeMoney, this.imgArray[8], this.imgArray[7], this.imgArray[4], Constant.UI_START_X + 28, Constant.UI_START_Y + 175);
 
         //第二个
         Tools.drawRoundRect(g, this.imgArray[6], 0x9c9c9c, 318, 156, Constant.UI_START_X + 21, Constant.UI_START_Y + 220);
         iStartX = Constant.UI_START_X + 28;
         iStartY = Constant.UI_START_Y + 255;
         for (byte i = 0; i < 14; i++) {
             this.myItems.drawGoods(g, iStartX, iStartY, i, false, true);
             if (i == 6) {
                 iStartX = Constant.UI_START_X + 28;
                 iStartY = Constant.UI_START_Y + 299;
             } else {
                 iStartX += 44;
             }
         }
 
         //绘制玩家的的名称
         Tools.drawShadowString(g, (byte) 1, MainLogic.getInstance().gamePlayer.sPlayerName, Constant.UI_START_X + 28, Constant.UI_START_Y + 225, 0xFFFFFF, 0x000000);
         if (!this.bTradeLock[1]) {
             Tools.drawShadowString(g, (byte) 1, this.sArray[2], Constant.UI_START_X + 333 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + 225, 0xFFFFFF, 0x000000);
         } else {
             Tools.drawShadowString(g, (byte) 1, this.sArray[2], Constant.UI_START_X + 333 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + 225, 0xb3b3b3, 0x000000);
             g.drawImage(this.imgArray[3], Constant.UI_START_X + 333 - Constant.FONT_SMALL.stringWidth(this.sArray[2]) + ((Constant.FONT_SMALL.stringWidth(this.sArray[2]) - 15) >> 1), Constant.UI_START_Y + 225, 0);
         }
         Tools.drawMoney(g, this.lMoney, this.imgArray[8], this.imgArray[7], this.imgArray[4], Constant.UI_START_X + 28, Constant.UI_START_Y + 343);
         //操作选项
         Tools.drawOpWord(g, this.sArray[1], this.byButtonSelectIndex == 1 ? true : false, (byte) 1, this.imgArray[0], Constant.UI_START_X + 38, Constant.UI_START_Y + 380, 0xffffff, 0x39abc6, 0x333333);
         Tools.drawOpWord(g, this.sArray[2], this.byButtonSelectIndex == 2 ? true : false, (byte) 1, this.imgArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.sArray[2])) >> 1), Constant.UI_START_Y + 380, 0xffffff, 0x39abc6, 0x333333);
         Tools.drawOpWord(g, this.sArray[3], this.byButtonSelectIndex == 3 ? true : false, (byte) 1, this.imgArray[0], Constant.UI_START_X + Constant.DRAW_WIDTH - 38 - Constant.FONT_SMALL.stringWidth(this.sArray[3]), Constant.UI_START_Y + 380, 0xffffff, 0x39abc6, 0x333333);
 
         //绘制选中横条
         if (this.bySelectIndex == 5 || this.bySelectIndex == 6) {
             Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, iPositionY, Constant.DRAW_WIDTH);
         }
         //绘制选中状态
         if (this.bySelectIndex == 1 || this.bySelectIndex == 2) {
             this.iStartX = Constant.UI_START_X + 28 + ((this.bySubSelectIndex - 1) % 7) * 44;
             this.iStartY = Constant.UI_START_Y + 85 + ((this.bySubSelectIndex - 1) / 7) * 44;
             this.items.drawSelectStyle(g, this.iStartX, this.iStartY);
             if (this.items.checkColumnHasGoods((short) (this.bySubSelectIndex - 1))) {
 //                this.items.drawGoodsName(g, (short) (this.bySubSelectIndex - 1), Constant.UI_START_X + 333 - Constant.FONT_SMALL.stringWidth(this.items.getGoodsAlias((short) (this.bySubSelectIndex - 1))), Constant.UI_START_Y + 173);
                 if (bLock) {
                     Goods.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, this.iStartX, this.iStartY);
                 } else {
                     Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
                 }
             }
         } else if (this.bySelectIndex == 3 || this.bySelectIndex == 4) {
             this.iStartX = Constant.UI_START_X + 28 + ((this.bySubSelectIndex - 1) % 7) * 44;
             this.iStartY = Constant.UI_START_Y + 255 + ((this.bySubSelectIndex - 1) / 7) * 44;
             this.myItems.drawSelectStyle(g, this.iStartX, this.iStartY);
             if (this.myItems.checkColumnHasGoods((short) (this.bySubSelectIndex - 1))) {
 //                this.myItems.drawGoodsName(g, (short) (this.bySubSelectIndex - 1), Constant.UI_START_X + 333 - Constant.FONT_SMALL.stringWidth(this.myItems.getGoodsAlias((short) (this.bySubSelectIndex - 1))), Constant.UI_START_Y + 343);
                 if (bLock) {
                     Goods.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, this.iStartX, this.iStartY);
                 } else {
                     Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
                 }
             }
         }
        //#else
        //#if NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[2], this.sArray[4], this.sArray[5], this.sArray[0]);
        //#else
//#        Tools.drawFrame(g, this.imgArray[2], this.imgArray[1], this.sArray[4], this.sArray[5], this.sArray[0]);
        //#endif
//#        //绘制包裹背景
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1);
//#        Tools.drawRoundRect(g, this.imgArray[6], 0x989898, 232, 116, iStartX, Constant.UI_START_Y + 28 + UiInterFace.iScreenOffsetH);
//#        //绘制内容
//#        iStartX = iStartX + 5;
//#        iStartY = Constant.UI_START_Y + 55 + UiInterFace.iScreenOffsetH;
//#        for (byte i = 0; i < 14; i++) {
//#            this.items.drawGoods(g, iStartX, iStartY, i);
//#            if (i == 6) {
//#                iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#                iStartY = Constant.UI_START_Y + UiInterFace.iScreenOffsetH + 87;
//#            } else {
//#                iStartX += 32;
//#            }
//#        }
//#        //绘制玩家的的名称this.sTrader
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1);
//#        Tools.drawShadowString(g, (byte) 1, this.sTrader, iStartX + 5, Constant.UI_START_Y + 28 + ((27 - Constant.FONT_SMALL_HEIGHT) >> 1) + UiInterFace.iScreenOffsetH, 0x39abc6, 0x000000);
//#        //锁定
//#        if (!this.bTradeLock[0]) {
//#            Tools.drawShadowString(g, (byte) 1, this.sArray[2], iStartX + 225, Constant.UI_START_Y + 28 + ((27 - Constant.FONT_SMALL_HEIGHT) >> 1) + UiInterFace.iScreenOffsetH, 0x39abc6, 0x000000, g.RIGHT | g.TOP);
//#        } else {
//#            Tools.drawShadowString(g, (byte) 1, this.sArray[2], iStartX + 225 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + 28 + ((27 - Constant.FONT_SMALL_HEIGHT) >> 1) + UiInterFace.iScreenOffsetH, 0xb3b3b3, 0x000000, g.RIGHT | g.TOP);
//#            g.drawImage(this.imgArray[3], iStartX + 225 - Constant.FONT_SMALL.stringWidth(this.sArray[2]) + ((Constant.FONT_SMALL.stringWidth(this.sArray[2]) - 15) >> 1), Constant.UI_START_Y + 34 + UiInterFace.iScreenOffsetH, 0);
//#        }
//#        //绘制交易的钱数
//#        Tools.drawMoney(g, this.lTradeMoney, this.imgArray[8], this.imgArray[7], this.imgArray[4], iStartX, Constant.UI_START_Y + 124 + UiInterFace.iScreenOffsetH);
//#
//#        //第二个
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1);
//#        Tools.drawRoundRect(g, this.imgArray[6], 0x989898, 232, 116, iStartX, Constant.UI_START_Y + 150 + UiInterFace.iScreenOffsetH);
//#        iStartX = iStartX + 5;
//#        iStartY = Constant.UI_START_Y + 180 + UiInterFace.iScreenOffsetH;
//#        for (byte i = 0; i < 14; i++) {
//#            this.myItems.drawGoods(g, iStartX, iStartY, i);
//#            if (i == 6) {
//#                iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#                iStartY = Constant.UI_START_Y + 212 + UiInterFace.iScreenOffsetH;
//#            } else {
//#                iStartX += 32;
//#            }
//#        }
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#
//#        //绘制玩家的的名称//
//#        Tools.drawShadowString(g, (byte) 1, MainLogic.getInstance().gamePlayer.sPlayerName, iStartX, Constant.UI_START_Y + 152 + ((28 - Constant.FONT_SMALL_HEIGHT) >> 1) + UiInterFace.iScreenOffsetH, 0x39abc6, 0x000000);
//#        if (!this.bTradeLock[1]) {
//#            Tools.drawShadowString(g, (byte) 1, this.sArray[2], iStartX + 225 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + 152 + ((27 - Constant.FONT_SMALL_HEIGHT) >> 1) + UiInterFace.iScreenOffsetH, 0x39abc6, 0x000000);
//#        } else {
//#            Tools.drawShadowString(g, (byte) 1, this.sArray[2], iStartX + 225 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + 152 + ((27 - Constant.FONT_SMALL_HEIGHT) >> 1) + UiInterFace.iScreenOffsetH, 0xb3b3b3, 0x000000);
//#            g.drawImage(this.imgArray[3], iStartX + 225 - Constant.FONT_SMALL.stringWidth(this.sArray[2]) + ((Constant.FONT_SMALL.stringWidth(this.sArray[2]) - 15) >> 1), Constant.UI_START_Y + 158 + UiInterFace.iScreenOffsetH, 0);
//#        }
//#        Tools.drawMoney(g, this.lMoney, this.imgArray[8], this.imgArray[7], this.imgArray[4], iStartX, Constant.UI_START_Y + 248 + UiInterFace.iScreenOffsetH);
//#        //操作选项
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1);
//#        Tools.drawOpWord(g, this.sArray[1], this.byButtonSelectIndex == 1 ? true : false, (byte) 1, this.imgArray[0], iStartX, Constant.UI_START_Y + 274 + UiInterFace.iScreenOffsetH, 0xffffff, 0x39abc6, 0x333333);
//#        Tools.drawOpWord(g, this.sArray[2], this.byButtonSelectIndex == 2 ? true : false, (byte) 1, this.imgArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.sArray[2])) >> 1), Constant.UI_START_Y + 274 + UiInterFace.iScreenOffsetH, 0xffffff, 0x39abc6, 0x333333);
//#        Tools.drawOpWord(g, this.sArray[3], this.byButtonSelectIndex == 3 ? true : false, (byte) 1, this.imgArray[0], iStartX + 232 - Constant.FONT_SMALL.stringWidth(this.sArray[3]), Constant.UI_START_Y + 274 + UiInterFace.iScreenOffsetH, 0xffffff, 0x39abc6, 0x333333);
//#
//#        //绘制选中横条
//#        if (this.bySelectIndex == 5) {
//#            Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, Constant.UI_START_Y + 262 + UiInterFace.iScreenOffsetH, Constant.DRAW_WIDTH);
//#        } else if (this.bySelectIndex == 6) {
//#            Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, Constant.UI_START_Y + 276 + UiInterFace.iScreenOffsetH + Constant.FONT_SMALL_HEIGHT, Constant.DRAW_WIDTH);
//#        }
//#        //绘制选中状态
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#        if (this.bySelectIndex == 1 || this.bySelectIndex == 2) {
//#            iStartX = iStartX + ((this.bySubSelectIndex - 1) % 7) * 32;
//#            iStartY = Constant.UI_START_Y + 55 + ((this.bySubSelectIndex - 1) / 7) * 32 + UiInterFace.iScreenOffsetH;
//#            this.items.drawSelectStyle(g, iStartX, iStartY);
//#            if (this.items.checkColumnHasGoods((short) (this.bySubSelectIndex - 1))) {
//#                if (bLock) {
//#                    Goods.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, iStartX, iStartY);
//#                } else {
//#                    Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
//#                }
//#            }
//#        } else if (this.bySelectIndex == 3 || this.bySelectIndex == 4) {
//#            iStartX = iStartX + ((this.bySubSelectIndex - 1) % 7) * 32;
//#            iStartY = Constant.UI_START_Y + 180 + ((this.bySubSelectIndex - 1) / 7) * 32 + UiInterFace.iScreenOffsetH;
//#            this.myItems.drawSelectStyle(g, iStartX, iStartY);
//#            if (this.myItems.checkColumnHasGoods((short) (this.bySubSelectIndex - 1))) {
//#                if (bLock) {
//#                    Goods.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, iStartX + ((this.bySubSelectIndex - 1) % 7) * 32, Constant.UI_START_Y + 180 + ((this.bySubSelectIndex - 1) / 7) * 32 + UiInterFace.iScreenOffsetH);
//#                } else {
//#                    Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
//#                }
//#            }
//#        }
        //#if NOKIA_E72
//#         Tools.drawE72ScrollBar(g);
        //#endif
        //#endif
    }

    /***********************交易回应***************************************************************************/
    public void setTradeAnswer(long lTraderID, String sTrader, String desc, long lMoney) {
        this.lTraderID = lTraderID;
        this.sTrader = sTrader;
        this.sArray = new String[]{"交易请求", desc};
        this.lMoney = lMoney;
        MainLogic.getInstance().pushState(Constant.GAME_UI_TRADE_ANSWER, true);
    }

    /**
     * 交易回应界面资源初始化
     */
    public void initTradeAnswer() {
        this.byUiState = 0;
        this.bKeypressLock = false;
        //弹出层的标题
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[5];
             this.imgArray[0] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
             this.imgArray[1] = ResManager.createImage(90000044);
             this.imgArray[2] = ResManager.createImage(90000043);//文字
             this.imgArray[3] = ResManager.createImage(90000086);
             this.imgArray[4] = ResManager.createImage(90000090);
            //#else
//#            this.imgArray = new Image[2];
//#            this.imgArray[0] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
//#            this.imgArray[1] = ResManager.createImage(90000044);
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
//            System.out.print("弹出层图片载入异常");
        }
    }

    /**
     *交易回应界面逻辑更新
     */
    public void updateTradeAnswer() {
        if (this.byPopUpState < 4) {
            this.byPopUpState++;
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
            GameBean.L_PLAYER_ID = this.lTraderID;
            GameBean.BY_TYPE = 1;
            GameBean.BY_APPLY_RESULT = 1;
            GameBean.STR_CMD_PLAYER_NICK = this.sTrader;
            GameBean.I_MONEY = (int) this.lMoney;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_TRADE_ANSWER, Constant.SOCKET_MSG_TYPE_LOGIC);
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
            //this.openTrade(this.lMoney);
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
            GameBean.L_PLAYER_ID = this.lTraderID;
            GameBean.BY_TYPE = 1;
            GameBean.BY_APPLY_RESULT = 0;
            this.lTraderID = -1L;
            this.sTrader = null;
            GameBean.STR_CMD_PLAYER_NICK = null;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_TRADE_ANSWER, Constant.SOCKET_MSG_TYPE_LOGIC);
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        }
        MainCanvas.clearInput();
    }

    /**
     * 绘制交易j界面
     * @param g 
     */
    public void drawTradeAnswer(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + 25, Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 120) >> 1), 310, 120, this.imgArray[0], 0x9c9c9c, this.imgArray[1], 22, 0, 21, 10, this.imgArray[1], 0, 0, 22, 10, this.sArray[0], this.sArray[1]);
         Tools.drawBottom(g, this.imgArray[2], this.imgArray[4], this.imgArray[3]);
        //#else
//#        Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 80) >> 1), 232, 80, this.imgArray[0], 0x989898, imgArray[1], 0, 0, 22, 10, imgArray[1], 22, 0, 21, 10, this.sArray[0], this.sArray[1]);
        //#endif
    }

    /**
     * 清除界面资源
     */
    public void clear() {
        this.imgArray = null;
        this.iArray = null;
        this.sArray = null;
        this.sOpArray = null;
        this.items = null;
        this.bTradeLock = null;
        this.sTrader = null;
        this.sButton = null;
        //#if NOKIA_E72
//#         Tools.clearE72ScollBar();
        //#endif
        this.sTips = null;

    }

    public void setGoodsState(Goods goods, short shPos) {
        if (goods.checkColumnHasGoods(shPos)) {
            //#if NOKIA_S60V5
             this.iGoodsDescHeight = Tools.getParagraphHeight(goods.getGoodsDesc(shPos), 290, Constant.FONT_SMALL_HEIGHT);
            //#else
//#            this.iGoodsDescHeight = Tools.getParagraphHeight(goods.getGoodsDesc(shPos), 209, Constant.FONT_SMALL_HEIGHT);
            //#endif
            Tools.rollIndex = 0;
            Tools.lastUpdateTime = System.currentTimeMillis();
            if (MainLogic.getInstance().byGameState == Constant.GAME_UI_STORE_BUY) {
                this.makeGoodsPrice();
            }
            this.makeItemsTips(this.items, shPos, this.sGoodsPrice, null);
        }
    }

    /**
     * 从服务器获得物品的描述
     */
    private void getGoodsDescFromNet() {
        //#if NOKIA_E72
        //#else
        if (bWaitMSGBack || System.currentTimeMillis() - this.lastSendDescTime < 1000) {
            return;
        } else {
            switch (MainLogic.getInstance().byGameState) {
                case Constant.GAME_UI_STORE_BUY:
                case Constant.GAME_UI_WAREHOUSE:
                    if (this.items.checkColumnHasGoods(this.shPos) && !this.items.isGetGoodsDesc(this.shPos)) {
                        this.bWaitMSGBack = true;
                        this.shGetNetDescPos = this.shPos;
                        GameBean.STR_DESC_CDM_GOODS_KEY = this.items.getGoodsKey(shPos);
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_CHECK_STORE_DESC, Constant.SOCKET_MSG_TYPE_LOGIC);
                        this.lastSendDescTime = System.currentTimeMillis();
                    }
                    break;
                case Constant.GAME_UI_WAGE_STORE:
                    if (this.store[this.byTabIndex - 1].checkColumnHasGoods(this.shPos) && !this.store[this.byTabIndex - 1].isGetGoodsDesc(this.shPos)) {
                        this.bWaitMSGBack = true;
                        this.shGetNetDescPos = this.shPos;
                        this.byGetNetDescTabIndex = this.byTabIndex;
                        GameBean.STR_DESC_CDM_GOODS_KEY = this.store[this.byTabIndex - 1].getGoodsKey(shPos);
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_CHECK_STORE_DESC, Constant.SOCKET_MSG_TYPE_LOGIC);
                        this.lastSendDescTime = System.currentTimeMillis();
                    }
                    break;
                case Constant.GAME_UI_INGOT_STORE:
                    if (this.bySelectIndex == 2 || this.bySelectIndex == 3) {
                        if (this.store[this.byTabIndex - 1].checkColumnHasGoods(this.shPos) && !this.store[this.byTabIndex - 1].isGetGoodsDesc(this.shPos)) {
                            this.bWaitMSGBack = true;
                            byGetNetDescType = 1;
                            this.shGetNetDescPos = this.shPos;
                            this.byGetNetDescTabIndex = this.byTabIndex;
                            GameBean.STR_DESC_CDM_GOODS_KEY = this.store[this.byTabIndex - 1].getGoodsKey(shPos);
                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_CHECK_STORE_DESC, Constant.SOCKET_MSG_TYPE_LOGIC);
                            this.lastSendDescTime = System.currentTimeMillis();
                        }

                    } else if (this.bySelectIndex == 5) {
                        if (this.items.checkColumnHasGoods(this.shPos) && !this.items.isGetGoodsDesc(this.shPos)) {
                            this.bWaitMSGBack = true;
                            this.shGetNetDescPos = this.shPos;
                            byGetNetDescType = 2;
                            GameBean.STR_DESC_CDM_GOODS_KEY = this.items.getGoodsKey(shPos);
                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_CHECK_STORE_DESC, Constant.SOCKET_MSG_TYPE_LOGIC);
                            this.lastSendDescTime = System.currentTimeMillis();
                        }
                    }
                    break;
                case Constant.GAME_UI_INGOT_RECORD:
                    if (this.bySelectIndex == 1 || this.bySelectIndex == 2) {
                        if (this.myItems.checkColumnHasGoods(this.shPos) && !this.myItems.isGetGoodsDesc(this.shPos)) {
                            this.bWaitMSGBack = true;
                            byGetNetDescType = 1;
                            this.shGetNetDescPos = this.shPos;
                            this.byGetNetDescTabIndex = this.byTabIndex;
                            GameBean.STR_DESC_CDM_GOODS_KEY = this.myItems.getGoodsKey(shPos);
                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_CHECK_STORE_DESC, Constant.SOCKET_MSG_TYPE_LOGIC);
                            this.lastSendDescTime = System.currentTimeMillis();
                        }

                    } else if (this.bySelectIndex == 4) {
                        if (this.items.checkColumnHasGoods(this.shPos) && !this.items.isGetGoodsDesc(this.shPos)) {
                            this.bWaitMSGBack = true;
                            this.shGetNetDescPos = this.shPos;
                            byGetNetDescType = 2;
                            GameBean.STR_DESC_CDM_GOODS_KEY = this.items.getGoodsKey(shPos);
                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_CHECK_STORE_DESC, Constant.SOCKET_MSG_TYPE_LOGIC);
                            this.lastSendDescTime = System.currentTimeMillis();
                        }
                    }
                    break;
                default:
                    return;
            }
        }
        //#endif
    }

    /**
     * 设置物品的的描述信息
     * @param desc 
     */
    public void setGoodsDescFromNet(String desc) {
        switch (MainLogic.getInstance().byGameState) {
            case Constant.GAME_UI_STORE_BUY:
            case Constant.GAME_UI_WAREHOUSE:
                this.items.setGoodsDesc(this.shGetNetDescPos, desc, true);
                if (this.shGetNetDescPos == this.shPos) {
                    Tools.rollIndex = 0;
                    Tools.lastUpdateTime = System.currentTimeMillis();
                    //#if NOKIA_S60V5
                     this.iGoodsDescHeight = Tools.getParagraphHeight(this.items.getGoodsDesc(this.shPos), 290, Constant.FONT_SMALL_HEIGHT);
                    //#else
//#                    this.iGoodsDescHeight = Tools.getParagraphHeight(this.items.getGoodsDesc(this.shPos), 209, Constant.FONT_SMALL_HEIGHT);
                    //#endif
                }
                break;
            case Constant.GAME_UI_WAGE_STORE:
                this.store[this.byGetNetDescTabIndex - 1].setGoodsDesc(this.shGetNetDescPos, desc, true);
                if (this.byGetNetDescTabIndex == this.byTabIndex && this.shGetNetDescPos == this.shPos) {
                    Tools.rollIndex = 0;
                    Tools.lastUpdateTime = System.currentTimeMillis();
                    //#if NOKIA_S60V5
                     this.iGoodsDescHeight = Tools.getParagraphHeight(this.store[this.byGetNetDescTabIndex - 1].getGoodsDesc(this.shPos), 290, Constant.FONT_SMALL_HEIGHT);
                    //#else
//#                    this.iGoodsDescHeight = Tools.getParagraphHeight(this.store[this.byGetNetDescTabIndex - 1].getGoodsDesc(this.shPos), 209, Constant.FONT_SMALL_HEIGHT);
                    //#endif
                }
                break;
            case Constant.GAME_UI_INGOT_STORE:
                switch (this.byGetNetDescType) {
                    case 1:
                        this.store[this.byGetNetDescTabIndex - 1].setGoodsDesc(this.shGetNetDescPos, desc, true);
                        if ((this.bySelectIndex == 2 || this.bySelectIndex == 3) && this.byGetNetDescTabIndex == this.byTabIndex && this.shGetNetDescPos == this.shPos) {
                            Tools.rollIndex = 0;
                            Tools.lastUpdateTime = System.currentTimeMillis();
                            //#if NOKIA_S60V5
                             this.iGoodsDescHeight = Tools.getParagraphHeight(this.store[this.byGetNetDescTabIndex - 1].getGoodsDesc(this.shPos), 290, Constant.FONT_SMALL_HEIGHT);
                            //#else
//#                            this.iGoodsDescHeight = Tools.getParagraphHeight(this.store[this.byGetNetDescTabIndex - 1].getGoodsDesc(this.shPos), 209, Constant.FONT_SMALL_HEIGHT);
                            //#endif
                        }
                        break;
                    case 2:
                        this.items.setGoodsDesc(this.shGetNetDescPos, desc, true);
                        if (this.bySelectIndex == 5 && this.shGetNetDescPos == this.shPos) {
                            Tools.rollIndex = 0;
                            Tools.lastUpdateTime = System.currentTimeMillis();
                            //#if NOKIA_S60V5
                             this.iGoodsDescHeight = Tools.getParagraphHeight(this.items.getGoodsDesc(this.shPos), 290, Constant.FONT_SMALL_HEIGHT);
                            //#else
//#                            this.iGoodsDescHeight = Tools.getParagraphHeight(this.items.getGoodsDesc(this.shPos), 209, Constant.FONT_SMALL_HEIGHT);
                            //#endif
                        }
                        break;
                }
                break;
            case Constant.GAME_UI_INGOT_RECORD:
                switch (this.byGetNetDescType) {
                    case 1:
                        this.myItems.setGoodsDesc(this.shGetNetDescPos, desc, true);
                        if ((this.bySelectIndex == 2 || this.bySelectIndex == 3) && this.byGetNetDescTabIndex == this.byTabIndex && this.shGetNetDescPos == this.shPos) {
                            Tools.rollIndex = 0;
                            Tools.lastUpdateTime = System.currentTimeMillis();
                            //#if NOKIA_S60V5
                             this.iGoodsDescHeight = Tools.getParagraphHeight(this.myItems.getGoodsDesc(this.shPos), 290, Constant.FONT_SMALL_HEIGHT);
                            //#else
//#                            this.iGoodsDescHeight = Tools.getParagraphHeight(this.myItems.getGoodsDesc(this.shPos), 209, Constant.FONT_SMALL_HEIGHT);
                            //#endif
                        }
                        break;
                    case 2:
                        this.items.setGoodsDesc(this.shGetNetDescPos, desc, true);
                        if (this.bySelectIndex == 5 && this.shGetNetDescPos == this.shPos) {
                            Tools.rollIndex = 0;
                            Tools.lastUpdateTime = System.currentTimeMillis();
                            //#if NOKIA_S60V5
                             this.iGoodsDescHeight = Tools.getParagraphHeight(this.items.getGoodsDesc(this.shPos), 290, Constant.FONT_SMALL_HEIGHT);
                            //#else
//#                            this.iGoodsDescHeight = Tools.getParagraphHeight(this.items.getGoodsDesc(this.shPos), 209, Constant.FONT_SMALL_HEIGHT);
                            //#endif
                        }
                        break;
                }
                break;
            default:
                return;
        }
    }

    /**
     * 玩家完成交易
     * @param stateCode 
     */
    public void completeTrade(byte stateCode) {
        MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("交易提示", "交易失败");
                break;
            case 1:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("交易提示", "交易成功！");
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("交易提示", "金钱不足");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("交易提示", "金钱不足");
                break;
            case 4:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("交易提示", "宠物栏已满");
                break;
            case 5:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("交易提示", "物品栏已满");
                break;
            case 6:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("交易提示", "宠物栏已满");
                break;
            case 7:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("交易提示", "背包已满，无法交易");
                break;
            case 8:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("交易提示", "没锁定交易");
                break;
            case 9:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("交易提示", "没锁定交易");
                break;
            case 10:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("交易提示", "系统错误");
                break;
        }

    }

    /**
     * 记录包裹中已经被选着的物品
     * @param index 记录的位置
     * @param opState 是删除还是添加,0:删除，1，添加
     * @param packageIndex  包裹的索引
     * @param shPos :包裹中的索引
     */
    public void setTradePackageAlreadySelected(short index, byte opState, byte packageIndex, short shPos) {
        if (opState == 1) {
            this.shSelectIndex[index * 2] = packageIndex;
            this.shSelectIndex[index * 2 + 1] = shPos;
        } else if (opState == 0) {
            this.shSelectIndex[index * 2] = -1;
            this.shSelectIndex[index * 2 + 1] = -1;
        }
    }

    /*********************玩家仓库和帮派仓库******************************************************/
    /**
     * 打开仓库
     * @param byWareHouseType
     * @param shMaxColumnNum
     * @param lNpcID
     */
    public void openWareHouse(byte byWareHouseType, short shMaxColumnNum, long lNpcID) {
        this.shMaxColumnNum = shMaxColumnNum;
        this.byWareHouseType = byWareHouseType;
        this.lNpcID = lNpcID;
        MainLogic.getInstance().pushState(Constant.GAME_UI_WAREHOUSE, true);
    }

    /**
     * 存储物品
     * @param stateCode
     */
    public void storageItems(byte stateCode) {
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "操作失败");
                break;
            case 1:
                if (this.byOpState == 1) {
                    MainLogic.getInstance().uiPackage.deleteGoods(MainLogic.getInstance().uiPackage.shPos);
                } else if (this.byOpState == 2) {
                    this.items.deleteGoods(this.shPos);
                } else if (this.byOpState == 3) {
                    for (short i = 0; i < this.items.getMaxColumNum(); i++) {
                        this.items.deleteGoods(i);
                    }
                }
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "背包里槽失效,无法移动到仓库");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "个人仓库已满");
                break;
            case 4:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "帮派仓库已满");
                break;
            case 5:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物栏已满");
                break;
            case 6:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "任务栏已满");
                break;
            case 7:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品栏已满");
                break;
            case 8:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "人物背包已满");
                break;
        }
    }

    /**
     * 初始化仓库资源
     */
    public void initWareHouse() {
        /***** 测试 * ***/
//       //        this.items = new Goods((short) 0, Constant.ITEM_COLUMN_TYPE_COMMON);
//        this.items.addGoods((short) 0, true, -1, (short) -1, "下坡", (short) 1, 1181, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 1, true, -1, (short) -1, "下坡2", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 2, true, -1, (short) -1, "下坡3", (short) 1, 1183, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 3, true, -1, (short) -1, "下坡4", (short) 1, 1171, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
        /***** 测试 * ***/
        bKeypressLock = false;
        bySelectIndex = 1;
        bySubSelectIndex = 1;
        this.byState = 0;
        this.shPos = 0;
        this.bWaitMSGBack = false;
        this.sArray = new String[]{"全部取出", ""};//(0键快速翻页)
        this.sGoodsPrice = null;
        this.byTotalPage = (byte) Math.max(Tools.ceil(this.shMaxColumnNum, 28), 1);
        this.byCurrentPage = 1;
        //界面中的位置的统一配置
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 140;
        //#elif NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 10;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 73;
        //#endif
        iPositionY = this.iStartPointY + 39;
        this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 223) >> 1);
        try {
            //#if NOKIA_S60V5
             imgArray = new Image[7];
             this.imgArray[0] = ResManager.createImage(90000041);  //箭头图片
             this.imgArray[1] = Tools.makeBlueMask();//蓝色光片
             this.imgArray[2] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角图片
             this.imgArray[3] = ResManager.createImage(90000047);//大数字
             this.imgArray[4] = ResManager.createImage(90000090);//方向键
             this.imgArray[5] = ResManager.createImage(90000086);//蓝条
             this.imgArray[6] = ResManager.createImage(90000043);//文字
            //#else
//#            imgArray = new Image[4];
//#            this.imgArray[0] = ResManager.createImage(90000041);  //箭头图片
//#            this.imgArray[1] = Tools.makeBlueMask();//蓝色光片
//#            this.imgArray[2] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角图片
//#            this.imgArray[3] = ResManager.createImage(90000047);//大数字
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
        this.setGoodsState(items, shPos);
    }

    /**
     * 更新仓库逻辑
     */
    public void updateWareHouse() {
        if (!GameBean.b_WAIT_NET_MSG_BACK) {
            if (!bKeypressLock) {
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                    if (this.bySelectIndex > 1) {
                        this.bySelectIndex -= 1;
                        switch (this.bySelectIndex) {
                            case 5:
                                this.shPos = -1;
                                break;
                            case 4:
                                this.shPos = (short) ((this.byCurrentPage - 1) * 28 + 21);
                                setGoodsState(this.items, this.shPos);
                                break;
                            default:
                                this.shPos -= 7;
                                break;

                        }
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                    if (this.bySelectIndex < 6) {
                        this.bySelectIndex += 1;
                        switch (this.bySelectIndex) {
                            case 5:
                                this.shPos = -1;
                                break;
                            default:
                                this.shPos += 7;
                                setGoodsState(this.items, this.shPos);
                                break;
                        }
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                    if (this.bySelectIndex < 5) {
                        this.shPos = (short) (this.shPos == (this.byCurrentPage - 1) * 28 ? this.shPos : this.shPos - 1);
                        this.bySelectIndex = (byte) ((this.shPos - (this.byCurrentPage - 1) * 28) / 7 + 1);
                        setGoodsState(this.items, this.shPos);
                    } else if (bySelectIndex == 5) {
                        this.byCurrentPage = (byte) (this.byCurrentPage > 1 ? this.byCurrentPage - 1 : this.byCurrentPage);
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                    if (this.bySelectIndex < 5) {
                        this.shPos = (short) (this.shPos == (this.byCurrentPage - 1) * 28 + 27 ? this.shPos : this.shPos + 1);
                        this.bySelectIndex = (byte) ((this.shPos - (this.byCurrentPage - 1) * 28) / 7 + 1);
                        setGoodsState(this.items, this.shPos);
                    } else if (bySelectIndex == 5) {
                        this.byCurrentPage = (byte) (this.byCurrentPage < this.byTotalPage ? this.byCurrentPage + 1 : this.byCurrentPage);
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_0, false)) {
                    this.bySelectIndex = 5;
                    this.byCurrentPage = (byte) (this.byCurrentPage == this.byTotalPage ? 1 : this.byCurrentPage + 1);
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                    if (this.bySelectIndex >= 1 && this.bySelectIndex <= 4) {
                        if (this.items.checkColumnHasGoods(this.shPos)) {
                            //发送将物品存入包裹中的指令
                            GameBean.BY_TYPE = 2;
                            GameBean.L_NPC_ID = this.lNpcID;
                            GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey(shPos);
                            this.byOpState = 2;
                            GameBean.b_WAIT_NET_MSG_BACK = true;
                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_DEPOT, Constant.SOCKET_MSG_TYPE_LOGIC);
                        } else {
                            MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                        }
                    } else if (this.bySelectIndex == 6) {
                        //发送全部取出的指令
                        GameBean.BY_TYPE = 3;
                        this.byOpState = 3;
                        GameBean.L_NPC_ID = this.lNpcID;
                        GameBean.b_WAIT_NET_MSG_BACK = true;
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_DEPOT, Constant.SOCKET_MSG_TYPE_LOGIC);
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                    MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                } else {
                    if (!MainLogic.getInstance().uiPackage.bShowBAG && !this.bWaitMSGBack && this.bySelectIndex == 1 && this.bySelectIndex <= 4 && this.items.checkColumnHasGoods(shPos) && !this.items.isGetGoodsDesc(shPos)) {
                        this.bWaitMSGBack = true;
                        this.shGetNetDescPos = this.shPos;
                        GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey(shPos);
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_CHECK_DESC, Constant.SOCKET_MSG_TYPE_LOGIC);
                    }
                }
            } else {
                if (this.byState == 1 || this.byState == 2) {
                    iPositionY = Tools.updateLinePos(this.iArray, iPositionY);
                    if (this.iArray == null || this.iArray[1] == 0) {
                        this.byState = 0;
                        this.bKeypressLock = false;
                    }
                }
            }
        }
        MainCanvas.clearInput();
    }

    /**
     * 获知仓库界面
     * @param g
     */
    public void drawWareHouse(Graphics g) {
        //#if NOKIA_S60V5
         //绘制背景
         this.iStartX = Constant.UI_START_X + 28;
         Tools.drawTilePic(g, (byte) 1, Constant.UI_START_X - 1, this.iStartPointY, Constant.DRAW_WIDTH + 2, this.imgArray[2], 28, 0, 13, 13, Constant.TRANS_NONE);
         Tools.drawTilePic(g, (byte) 1, Constant.UI_START_X - 1, this.iStartPointY + 240, Constant.DRAW_WIDTH + 2, this.imgArray[2], 14, 14, 13, 13, Constant.TRANS_NONE);
         g.setColor(0x9c9c9c);
         g.fillRect(Constant.UI_START_X, this.iStartPointY + 13, Constant.DRAW_WIDTH, 227);
         //全部取出，全部存储
         Tools.drawOpWord(g, this.sArray[0], this.bySelectIndex == 6 ? true : false, (byte) 1, null, this.iStartX, this.iStartPointY + 190 + Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x46aeeb, 0x000000);
         //绘制物品
         Tools.drawPackageBox(g, items, this.imgArray[3], this.imgArray[0], sArray[1], this.iStartX, this.iStartPointY + 10, this.byCurrentPage, this.byTotalPage, null, null);
         //绘制物品的选中状态(最上层。防止被覆盖)
         //绘制显示物品描述的背景
         Tools.drawRoundRect(g, this.imgArray[2], 0x9c9c9c, 310, 80, Constant.UI_START_X + 25, Constant.UI_START_Y + 400);
         //绘制选中横条
         switch (this.bySelectIndex) {
             case 5:
                 Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 44 * 4 + 25, Constant.DRAW_WIDTH);
                 break;
             case 6:
                 Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 15 + 44 * 4 + (Constant.FONT_SMALL_HEIGHT << 1), Constant.DRAW_WIDTH);
                 break;
         }
         if (this.bySelectIndex >= 1 && this.bySelectIndex <= 4) {
             if (this.shPos >= 0) {
                 if (this.shPos % 7 == 0) {
                     iStartY = this.iStartPointY + 10 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 44;
                 } else {
                     this.iStartX = this.iStartX + (this.shPos % 7) * 44;
                     iStartY = this.iStartPointY + 10 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 44;
                 }
                 this.items.drawSelectStyle(g, iStartX, iStartY);
                 if (this.items.checkColumnHasGoods(shPos)) {
                     Tools.drawHCycleRollingParagraph(g, this.items.getGoodsDesc(this.shPos), this.iGoodsDescHeight, 290, 60, Constant.FONT_SMALL_HEIGHT, Constant.UI_START_X + 35, Constant.UI_START_Y + 410, 0xFFFFFF, -1);
                     Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
                 }
             }
         }
         Tools.drawBottom(g, this.imgArray[6], this.imgArray[4], this.imgArray[5]);
        //#else
//#        //绘制背景
//#        this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - Goods.byItemH * 7 + 1) >> 1);
//#        Tools.drawTilePic(g, (byte) 1, Constant.UI_START_X, this.iStartPointY, Constant.DRAW_WIDTH, this.imgArray[2], 21, 0, 6, 7, Constant.TRANS_NONE);
//#        Tools.drawTilePic(g, (byte) 1, Constant.UI_START_X, this.iStartPointY + 183 - 7, Constant.DRAW_WIDTH, this.imgArray[2], 21, 7, 6, 7, Constant.TRANS_NONE);
//#        g.setColor(0x989898);
//#        g.fillRect(Constant.UI_START_X, this.iStartPointY + 7, Constant.DRAW_WIDTH, 169);
//#        Tools.drawOpWord(g, this.sArray[0], this.bySelectIndex == 6 ? true : false, (byte) 1, null, this.iStartX, this.iStartPointY + 137 + Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x46aeeb, 0x000000);
//#        //绘制物品
//#        Tools.drawPackageBox(g, items, this.imgArray[3], this.imgArray[0], sArray[1], this.iStartX, this.iStartPointY + 7, this.byCurrentPage, this.byTotalPage, null, null);
//#        //绘制选中横条
//#        switch (this.bySelectIndex) {
//#            case 5:
//#                Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 32 * 4 + 22, Constant.DRAW_WIDTH);
//#                break;
//#            case 6:
//#                Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 10 + 32 * 4 + (Constant.FONT_SMALL_HEIGHT << 1), Constant.DRAW_WIDTH);
//#                break;
//#
//#        }
//#
//#        //绘制物品的选中状态(最上层。防止被覆盖)
//#        if (this.bySelectIndex >= 1 && this.bySelectIndex <= 4) {
//#            if (this.shPos >= 0) {
//#                if (this.shPos % 7 == 0) {
//#                    iStartY = this.iStartPointY + 7 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 32;
//#                } else {
//#                    this.iStartX = this.iStartX + (this.shPos % 7) * 32;
//#                    iStartY = this.iStartPointY + 7 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 32;
//#                }
//#                this.items.drawSelectStyle(g, iStartX, iStartY);
//#                if (this.items.checkColumnHasGoods(shPos)) {
                    //#if NOKIA_E72
//#                     Tools.drawRoundRect(g, this.imgArray[2], 0x989898, 300, 40, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 300) >> 1), this.iStartPointY + 185);
//#                     Tools.drawHCycleRollingParagraph(g, this.items.getGoodsDesc(this.shPos), this.iGoodsDescHeight, 290, 36, Constant.FONT_SMALL_HEIGHT, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 300) >> 1) + 5, this.iStartPointY + 187, 0xFFFFFF, -1);
                    //#else
//#                    Tools.drawRoundRect(g, this.imgArray[2], 0x989898, 232, 56, Constant.UI_START_X + 4, this.iStartPointY + 187);
//#                    Tools.drawHCycleRollingParagraph(g, this.items.getGoodsDesc(this.shPos), this.iGoodsDescHeight, 209, 52, Constant.FONT_SMALL_HEIGHT, Constant.UI_START_X + 4 + 7, this.iStartPointY + 189, 0xFFFFFF, -1);
                    //#endif
//#                    Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
//#                }
//#            }
//#        }
        //#endif
         //Yujiang
         MainView.drawTouchRect(g, mPackagePageTouchRect2);
         MainView.drawTouchRect(g, mGetAllTouchRect);
         MainView.drawTouchRect(g, mPackageTouchRect2);
    }

    /**
     * 清除仓库资源
     */
    public void clearWareHouse() {
        this.sArray = null;
        this.iArray = null;
        this.items = null;
        this.imgArray = null;
        this.sTips = null;
    }

    /***************************工资商城******************************************************/
    public void changeToNewTab(byte bySelectIndex) {
        switch (MainLogic.getInstance().byGameState) {
            case Constant.GAME_UI_WAGE_STORE:
                this.byTotalPage = (byte) Tools.ceil(this.store[this.byTabIndex - 1].getMaxColumNum(), 28);
                this.byCurrentPage = 1;
                this.bySelectIndex = bySelectIndex;
                if (bySelectIndex == 1) {
                    this.bySubSelectIndex = -1;
                    this.shPos = -1;
                    this.iGoodsDescHeight = 0;
                    //#if NOKIA_S60V5
                     this.iPositionY = this.iStartPointY + 35;
                    //#else
//#                    this.iPositionY = this.iStartPointY + 28;
                    //#endif
                } else if (bySelectIndex == 2) {
                    this.bySubSelectIndex = 1;
                    this.shPos = 0;
                    this.iGoodsDescHeight = 0;
                    if (this.store[this.byTabIndex - 1].checkColumnHasGoods((short) 0)) {
                        //#if NOKIA_S60V5
                         this.iGoodsDescHeight = Tools.getParagraphHeight(this.store[this.byTabIndex - 1].getGoodsDesc((short) 0), 290, Constant.FONT_SMALL_HEIGHT);
                        //#else
//#                        this.iGoodsDescHeight = Tools.getParagraphHeight(this.store[this.byTabIndex - 1].getGoodsDesc((short) 0), 209, Constant.FONT_SMALL_HEIGHT);
                        //#endif
                        this.sArray[3] = "售价：" + this.store[this.byTabIndex - 1].getGoodsPrice(this.shPos);
                    }
                    //#if NOKIA_S60V5
                     this.iPositionY = this.iStartPointY + 38 + 44;
                    //#else
//#                    this.iPositionY = this.iStartPointY + 28 + 32;
                    //#endif
                }
                break;
            case Constant.GAME_UI_INGOT_STORE:
                this.byTotalPage = (byte) Math.max(Tools.ceil(this.store[this.byTabIndex - 1].getMaxColumNum(), 14), 1);
                this.byCurrentPage = 1;
                this.bySelectIndex = bySelectIndex;
                if (bySelectIndex == 1) {
                    this.bySubSelectIndex = -1;
                    this.shPos = -1;
                    this.iGoodsDescHeight = 0;
                    //#if NOKIA_S60V5
                     this.iPositionY = this.iStartPointY + 35;
                    //#else
//#                    this.iPositionY = this.iStartPointY + 28;
                    //#endif
                } else if (bySelectIndex == 2) {
                    this.bySubSelectIndex = 1;
                    this.shPos = 0;
                    this.iGoodsDescHeight = 0;
                    this.iPositionY = Constant.UI_START_X + 120;
                    if (this.store[this.byTabIndex - 1].checkColumnHasGoods((short) 0)) {
                        //#if NOKIA_S60V5
                         this.iGoodsDescHeight = Tools.getParagraphHeight(this.store[this.byTabIndex - 1].getGoodsDesc((short) 0), 290, Constant.FONT_SMALL_HEIGHT);
                        //#else
//#                        this.iGoodsDescHeight = Tools.getParagraphHeight(this.store[this.byTabIndex - 1].getGoodsDesc((short) 0), 209, Constant.FONT_SMALL_HEIGHT);
                        //#endif
                        this.sArray[3] = "售价：" + this.store[this.byTabIndex - 1].getGoodsPrice(this.shPos);
                    }
                    //#if NOKIA_S60V5
                     this.iPositionY = this.iStartPointY + 38 + 44;
                    //#else
//#                    this.iPositionY = this.iStartPointY + 28 + 32;
                    //#endif
                }
                break;
        }

    }

    /**
     * 服务器类型和客户端类型转换
     * @param bySubType
     * @param byType
     * @return 
     */
    public byte ingotStoreSubTypeConvert(byte bySubType, byte byType) {
        switch (byType) {
            //64:热卖2 :辅助 4:装备8：宠物16：宝石32：技能
            case 1://元宝商城
                switch (bySubType) {
                    case 1:
                        return 64;
                    case 2:
                        return 2;
                    case 3:
                        return 4;
                    case 4:
                        return 8;
                    case 5:
                        return 16;
                    case 6:
                        return 32;

                }
                break;
            case 2://工资商城
                switch (bySubType) {
                    case 2:
                        return 2;
                    case 4:
                        return 3;
                    case 8:
                        return 4;
                    case 16:
                        return 5;
                    case 32:
                        return 6;
                    case 64:
                        return 1;
                }
                break;
        }
        return -1;
    }

    /**
     * 服务器类型和客户端类型转换
     * @param bySubType
     * @param byType
     * @return 
     */
    public byte wageStoreSubTypeConvert(byte bySubType, byte byType) {
        switch (byType) {//2 :辅助 4：装备8：宠物16：宝石32：技能64:热卖
            case 1://
                switch (bySubType) {
                    case 1:
                        return 2;
                    case 2:
                        return 4;
                    case 3:
                        return 8;
                    case 4:
                        return 16;
                    case 5:
                        return 32;
                }
                break;
            case 2:
                switch (bySubType) {
                    case 2:
                        return 1;
                    case 4:
                        return 2;
                    case 8:
                        return 3;
                    case 16:
                        return 4;
                    case 32:
                        return 5;
                }
                break;
        }
        return -1;
    }

    /**
     *打开元宝/工资商城
     * @param byIngotStoreType
     * @param bySubType 
     */
    public void openIngotStore(byte byIngotStoreType, byte bySubType) {
        switch (byIngotStoreType) {
            case 1://元宝商城
                GameBean.BY_TYPE = 1;
                GameBean.BY_OP_TYPE = ingotStoreSubTypeConvert(bySubType, (byte) 1);
                if (GameBean.BY_OP_TYPE == -1) {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "没有这种类型的商店");
                    return;
                }
                GameBean.BY_TRUE = (byte) ((MainLogic.getInstance().byGameState == Constant.GAME_UI_INGOT_STORE) ? 0 : 1);
                GameBean.b_WAIT_NET_MSG_BACK = true;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_INGOT_STORE, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
            case 2://工资商城
                GameBean.BY_TYPE = 2;
                GameBean.BY_OP_TYPE = wageStoreSubTypeConvert(bySubType, (byte) 1);
                if (GameBean.BY_OP_TYPE == -1) {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "没有这种类型的商店");
                    return;
                }
                GameBean.BY_TRUE = (byte) ((MainLogic.getInstance().byGameState == Constant.GAME_UI_WAGE_STORE) ? 0 : 1);
                GameBean.b_WAIT_NET_MSG_BACK = true;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_INGOT_STORE, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
        }
    }

    /**
     * 初始化
     */
    public byte initOpenStore(byte byIngotStoreType, short shGoodsNum, byte bySubType) {
        switch (byIngotStoreType) {
            case 1:
                bySubType = this.ingotStoreSubTypeConvert(bySubType, (byte) 2);
                if (MainLogic.getInstance().byGameState != Constant.GAME_UI_INGOT_STORE) {
                    MainLogic.getInstance().pushState(Constant.GAME_UI_INGOT_STORE, true);
                }
                this.shPos = -1;
                this.bySelectIndex = 1;
                this.iGoodsDescHeight = 0;
                if (this.store[bySubType - 1] == null) {
                    this.store[bySubType - 1] = new Goods(shGoodsNum, Constant.ITEM_COLUMN_TYPE_COMMON);
                } else {
                    this.store[bySubType - 1].init(shGoodsNum, Constant.ITEM_COLUMN_TYPE_COMMON);
                }
                this.byTabIndex = bySubType;
                this.byGetDataFromNet[bySubType - 1] = 1;
                this.byTotalPage = (byte) Math.max(Tools.ceil(shGoodsNum, 14), 1);
                this.byCurrentPage = 1;
                return bySubType;
            case 2:
                bySubType = this.wageStoreSubTypeConvert(bySubType, (byte) 2);
                if (MainLogic.getInstance().byGameState != Constant.GAME_UI_WAGE_STORE) {
                    MainLogic.getInstance().pushState(Constant.GAME_UI_WAGE_STORE, true);
                }
                this.shPos = -1;
                this.bySelectIndex = 1;
                this.iGoodsDescHeight = 0;
                if (this.store[bySubType - 1] == null) {
                    this.store[bySubType - 1] = new Goods(shGoodsNum, Constant.ITEM_COLUMN_TYPE_COMMON);
                } else {
                    this.store[bySubType - 1].init(shGoodsNum, Constant.ITEM_COLUMN_TYPE_COMMON);
                }
                this.byGetDataFromNet[bySubType - 1] = 1;
                this.byTabIndex = bySubType;
                this.byTotalPage = (byte) Math.max(Tools.ceil(shGoodsNum, 14), 1);
                this.byCurrentPage = 1;
                return bySubType;
        }
        return -1;
    }

    public void setPlayerIngot(byte bShetPlayerInfo, short shPlayerBag, short shPlayerNowBag, int PlayerIngot) {
        if (bShetPlayerInfo == 1) {
            this.lMoney = PlayerIngot;
            this.shPlayerBag = shPlayerBag;
            this.shPlayerNowBag = shPlayerNowBag;
            switch (MainLogic.getInstance().byGameState) {
                case Constant.GAME_UI_INGOT_STORE:
                    this.sArray[1] = "背包：" + shPlayerNowBag + "/" + shPlayerBag;
                    this.sArray[2] = "元宝：" + PlayerIngot;
                    break;
                case Constant.GAME_UI_WAGE_STORE:
                    this.sArray[1] = "背包：" + shPlayerNowBag + "/" + shPlayerBag;
                    this.sArray[2] = "元宝：" + PlayerIngot;
                    break;
            }
        }
    }
    private byte[] byGetDataFromNet;
    private byte byTabNum = 0;

    public void initWageStore() {
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 46;
         this.iPositionY = this.iStartPointY + 35;
        //#elif NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 21;
//#         this.iPositionY = this.iStartPointY + 25;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 26;
//#        this.iPositionY = this.iStartPointY + 25;
        //#endif
        this.lMoney = 0;
        this.shPlayerBag = 0;
        this.shPlayerNowBag = 0;
        bLock = false;
//        this.sIngotTabTitle = new String[]{"1 辅助", "2 装备", "3 宠物", "4 宝石", "5 技能"};
        this.byTabNum = 4;
        this.sIngotTabTitle = new String[]{"1 辅助", "2 装备", "3 宠物", "4 宝石"};
        this.store = new Goods[this.byTabNum];
        this.byTabIndex = 1;
        byGetDataFromNet = new byte[this.byTabNum];
        for (byte i = 0; i < this.byTabNum; i++) {
            byGetDataFromNet[i] = 0;
        }
        this.bySelectIndex = 1;
        this.byTotalPage = 1;
        this.byCurrentPage = 1;
        /*****/
//        for (byte i = 0; i < 5; i++) {
//            this.store[i] = new Goods((short) 0, Constant.ITEM_COLUMN_TYPE_COMMON);
//            this.store[i].addGoods((short) 0, true, -1, (short) -1, "下坡", (short) 1, 1181, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//            this.store[i].addGoods((short) 1, true, -1, (short) -1, "下坡", (short) 1, 1181, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//            this.store[i].addGoods((short) 2, true, -1, (short) -1, "下坡", (short) 1, 1181, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        }
//        byGetDataFromNet = new byte[]{1, 1, 1, 1, 1};
        /*****/
        this.bWaitMSGBack = false;
        this.sArray = new String[]{"工资商城", "背包：0/0", "元宝：0", "售价:0", "合计：0", "请输入您要购买的物品数量", "等级"};
        this.sOpArray = new String[]{"购买", "查看"};
        this.sButton = new String[]{"确定", "返回", ""};//(0键快速翻页)
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[13];
             this.imgArray[0] = ResManager.createImage(90000041);    //箭头图片
             this.imgArray[1] = Tools.makeBlueMask();//蓝色光片
             this.imgArray[2] = ResManager.createImage(90000017);//背景图片
             this.imgArray[3] = ResManager.createImage(90000041);//白色确定
             this.imgArray[4] = ResManager.createImage(90000047);//大数字图片
             this.imgArray[5] = ResManager.createImage(90000060);//文字图片
             this.imgArray[6] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角图片
             this.imgArray[8] = ResManager.createImage(90000082);//元宝图片
             this.imgArray[9] = ResManager.createImage(90000043);//文字
             this.imgArray[10] = ResManager.createImage(90000084);//方向键
             this.imgArray[11] = ResManager.createImage(90000085);//确认
             this.imgArray[7] = ResManager.createImage(90000086);//蓝条
            //#else
//#            this.imgArray = new Image[9];
//#            this.imgArray[0] = ResManager.createImage(90000041);    //箭头图片 
//#            this.imgArray[1] = Tools.makeBlueMask();//蓝色光片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[2] = ResManager.createImage(90000017);
//# //            imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            this.imgArray[2] = ResManager.createImage(90000017);//背景图片
            //#endif
//#            this.imgArray[3] = ResManager.createImage(90000044);//白色确定
//#            this.imgArray[4] = ResManager.createImage(90000047);//大数字图片
//#            this.imgArray[5] = ResManager.createImage(90000043);//文字图片
//#            this.imgArray[6] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角图片
//#            this.imgArray[7] = Tools.makeTransparent(Constant.DRAW_WIDTH, 10, 140, 0x000000);//弹出背景遮罩层
//#            this.imgArray[8] = ResManager.createImage(90000082);//元宝图片
            //#endif
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.lastSendDescTime = System.currentTimeMillis();
    }

    public void updateWageStore() {
        switch (this.byUiState) {
            case 0:
                if (!GameBean.b_WAIT_NET_MSG_BACK) {
                    if (!bKeypressLock) {
                        if (!bLock) {
                            //非弹出物品操作菜单
                            if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                if (this.bySelectIndex > 1) {
                                    this.bySelectIndex -= 1;
                                    switch (this.bySelectIndex) {
                                        case 1:
                                            this.shPos = -1;
                                            break;
                                        case 2:
                                        case 3:
                                        case 4:
                                            this.shPos -= 7;
                                            this.setIngotGoodsState(this.store[this.byTabIndex - 1], this.shPos);
                                            break;
                                        case 5:
                                            this.shPos = (short) ((this.byCurrentPage - 1) * 28 + 21);
                                            this.setIngotGoodsState(this.store[this.byTabIndex - 1], this.shPos);
                                            break;
                                    }
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                if (this.bySelectIndex < 6) {
                                    this.bySelectIndex += 1;
                                    switch (this.bySelectIndex) {
                                        case 2:
                                            this.shPos = (short) ((this.byCurrentPage - 1) * 28);
                                            this.setIngotGoodsState(this.store[this.byTabIndex - 1], this.shPos);
                                            break;
                                        case 3:
                                        case 4:
                                        case 5:
                                            this.shPos += 7;
                                            this.setIngotGoodsState(this.store[this.byTabIndex - 1], this.shPos);
                                            break;
                                        case 6:
                                            this.shPos = -1;
                                            break;
                                    }
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                        byTabIndex = (byte) (byTabIndex == 1 ? this.byTabNum : byTabIndex - 1);
                                        if (byTabIndex > 1) {
                                            if (this.byGetDataFromNet[this.byTabIndex - 1] == 1) {
                                                this.changeToNewTab((byte) 1);
                                            } else {
                                                openIngotStore((byte) 2, this.byTabIndex);
                                                return;
                                            }
                                        }
                                        break;
                                    case 2:
                                    case 3:
                                    case 4:
                                    case 5:
                                        this.shPos = (short) (this.shPos == (this.byCurrentPage - 1) * 28 ? shPos : shPos - 1);
                                        this.setIngotGoodsState(this.store[this.byTabIndex - 1], this.shPos);
                                        break;
                                    case 6:
                                        if (this.byCurrentPage > 1) {
                                            this.byCurrentPage = (byte) (this.byCurrentPage - 1);
                                        }
                                        break;
                                }

                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_0, false)) {
                                this.bySelectIndex = 6;
                                this.byCurrentPage = (byte) (this.byCurrentPage == this.byTotalPage ? 1 : this.byCurrentPage + 1);
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_1, false)) {
                                if (this.byGetDataFromNet[0] == 1) {
                                    this.byTabIndex = 1;
                                    this.changeToNewTab((byte) 1);
                                } else {
                                    openIngotStore((byte) 2, (byte) 1);
                                    return;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_2, false)) {
                                if (this.byGetDataFromNet[0] == 1) {
                                    this.byTabIndex = 2;
                                    this.changeToNewTab((byte) 1);
                                } else {
                                    openIngotStore((byte) 2, (byte) 2);
                                    return;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_3, false)) {
                                if (this.byGetDataFromNet[0] == 1) {
                                    this.byTabIndex = 3;
                                    this.changeToNewTab((byte) 1);
                                } else {
                                    openIngotStore((byte) 2, (byte) 3);
                                    return;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_4, false)) {
                                if (this.byGetDataFromNet[3] == 1) {
                                    this.byTabIndex = 4;
                                    this.changeToNewTab((byte) 1);
                                } else {
                                    openIngotStore((byte) 2, (byte) 4);
                                    return;
                                }
                            } //                            else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                            //                                if (this.byGetDataFromNet[4] == 1) {
                            //                                    this.byTabIndex = 5;
                            //                                    this.changeToNewTab((byte) 1);
                            //                                } else {
                            //                                    openIngotStore((byte) 2, (byte) 5);
                            //                                    return;
                            //                                }
                            //                            } 
                            else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                        byTabIndex = (byte) (byTabIndex == this.byTabNum ? 1 : byTabIndex + 1);
                                        if (this.byGetDataFromNet[this.byTabIndex - 1] == 1) {
                                            this.changeToNewTab((byte) 1);
                                        } else {
                                            openIngotStore((byte) 2, this.byTabIndex);
                                            return;
                                        }
                                        break;
                                    case 2:
                                    case 3:
                                    case 4:
                                    case 5:
                                        this.shPos = (short) (this.shPos == (this.byCurrentPage - 1) * 28 + 27 ? shPos : shPos + 1);
                                        this.setIngotGoodsState(this.store[this.byTabIndex - 1], this.shPos);
                                        break;
                                    case 6:
                                        if (this.byCurrentPage < this.byTotalPage) {
                                            this.byCurrentPage = (byte) (this.byCurrentPage + 1);
                                        }
                                        break;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                                switch (this.bySelectIndex) {
                                    case 2:
                                    case 3:
                                    case 4:
                                    case 5:
                                        if (this.store[this.byTabIndex - 1].checkColumnHasGoods(this.shPos)) {
                                            this.bLock = true;
                                            this.byMenuIndex = 0;
                                        }
                                        break;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                Tools.openRoamMenu(false, (byte) 1, (byte) 1, 2);
                            } else {
                                if (this.bySelectIndex >= 2 && this.bySelectIndex <= 5) {
                                    this.getGoodsDescFromNet();
                                }
                            }
                        } else {
                            if (this.bySelectIndex < 2 || this.bySelectIndex > 5) {
                                this.bLock = false;
                                return;
                            } else {
                                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                    this.bLock = false;
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                    this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 0);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                    this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 1);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                                    this.bLock = false;
                                    switch (this.byMenuIndex) {
                                        case 0:
                                            //输入购买数量界面
                                            //#if NOKIA_S60V5
                                             MainLogic.getInstance().inputInterFace.setInputInterFace((byte) 1, "请输入要购买的物品数量:");
                                             MainLogic.getInstance().inputInterFace.commonInput.setString(String.valueOf(1));
                                             MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
                                            //#else
//#                                            this.byUiState = 1;
//#                                            this.sArray[4] = "合计：0";
//#                                            this.byBuyGoodsNum = 0;
                                            //#endif
                                            break;
                                        case 1:
                                            //查看道具界面
                                            GameBean.b_WAIT_NET_MSG_BACK = true;
                                            MainLogic.getInstance().uiInterFace.sysMessage.checkStoreItem(this.store[this.byTabIndex - 1].getGoodsAlias(this.shPos), this.store[this.byTabIndex - 1].getGoodsColor(this.shPos), this.store[this.byTabIndex - 1].icon[this.shPos], this.store[this.byTabIndex - 1].getGoodsKey(this.shPos));
                                            break;
                                    }
                                }
                            }
                        }
                    } else {
                        if (this.byState == 1 || this.byState == 2) {
                            iPositionY = Tools.updateLinePos(this.iArray, iPositionY);
                            if (this.iArray == null || this.iArray[1] == 0) {
                                this.byState = 0;
                                this.bKeypressLock = false;
                            }
                        }
                        MainCanvas.clearInput();
                    }
                }
                break;
            case 1:
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                    this.byUiState = 0;
                    if (this.byBuyGoodsNum < 1 || this.byBuyGoodsNum > 99) {
                        this.byBuyGoodsNum = 1;
                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您输入的数量不正确!");
                    } else {
                        //发送购买消息
                        this.buyIngotStoreGoods(this.byBuyGoodsNum);
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                    this.byUiState = 0;
                    this.byBuyGoodsNum = 0;
                } else {
                    this.byBuyGoodsNum = (byte) Tools.updateInputCanvas(this.byBuyGoodsNum, 99);
                    if (this.byBuyGoodsNum > -1) {
                        this.sArray[4] = "合计：" + this.store[this.byTabIndex - 1].getGoodsPrice(this.shPos) * this.byBuyGoodsNum;
                    } else {
                        this.sArray[4] = "合计：0";
                    }
                }
                this.bFlag = this.bFlag ? false : true;
                break;
            case 2:
                break;
        }
        MainCanvas.clearInput();
    }

    public void drawWageStore(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[10], this.imgArray[11], this.imgArray[7], this.imgArray[9], sArray[0]);
         //绘制包裹栏和任务栏的背景
         drawIngotPackageBg(g, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1), this.iStartPointY, this.imgArray[6], this.sIngotTabTitle, this.byTabIndex);
         //开始绘制包裹中的内容
         iStartX = Constant.UI_START_X + 28;
         iStartY = this.iStartPointY + 38;
         Tools.drawPackageBox(g, this.store[this.byTabIndex - 1], this.imgArray[4], this.imgArray[0], sButton[2], iStartX, iStartY, byCurrentPage, this.byTotalPage, null, null);
         //绘制玩家的背包数量和空余背包数量
         Tools.setColor(g, 0xFFFFFF);
         g.drawString(this.sArray[1], Constant.UI_START_X + 28, Constant.UI_START_Y + 395, 0);
         g.drawString(this.sArray[2], Constant.UI_START_X + Constant.DRAW_WIDTH - 51 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + 395, 0);
         g.drawImage(this.imgArray[8], Constant.UI_START_X + Constant.DRAW_WIDTH - 48, Constant.UI_START_Y + 395 + ((Constant.FONT_SMALL_HEIGHT - 12) >> 1), 0);
 
         //绘制玩家元宝数量
         //绘制选中横条
         if (this.bySelectIndex < 6) {
             Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 35, Constant.DRAW_WIDTH);
         } else if (this.bySelectIndex == 6) {
             Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 38 + 176 + Constant.FONT_SMALL_HEIGHT, Constant.DRAW_WIDTH);
         }
         //绘制物品的选中状态(最上层。防止被覆盖)
         if (this.bySelectIndex >= 2 && this.bySelectIndex <= 5) {
             if (this.shPos >= 0) {
                 if (this.shPos % 7 == 0) {
                     this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1) + 6;
                     iStartY = this.iStartPointY + 38 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 44;
                 } else {
                     this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1) + 6 + (this.shPos % 7) * 44;
                     iStartY = this.iStartPointY + 38 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 44;
                 }
                 this.store[this.byTabIndex - 1].drawSelectStyle(g, iStartX, iStartY);
                 if (this.store[this.byTabIndex - 1].checkColumnHasGoods(this.shPos)) {
                     //物品的描述
                     Tools.drawHCycleRollingParagraph(g, this.store[this.byTabIndex - 1].getGoodsDesc(this.shPos), this.iGoodsDescHeight, 290, 60, Constant.FONT_SMALL_HEIGHT, Constant.UI_START_X + 28, this.iStartPointY + 275, 0xFFFFFF, -1);
                     if (bLock) {
                         this.items.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, iStartX, iStartY);
                     } else {
                         //绘制物品的价格
                         Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH, this.imgArray[8], this.shTipsIngotPicStart);
                     }
                 }
             }
         }
        //#else
        //#if NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[2], this.sButton[0], this.sButton[1], sArray[0]);
        //#else
//#        Tools.drawFrame(g, this.imgArray[2], this.imgArray[1], this.sButton[0], this.sButton[1], sArray[0]);
        //#endif
//#        //绘制包裹栏和任务栏的背景
//#        drawIngotPackageBg(g, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), this.iStartPointY, this.imgArray[6], this.sIngotTabTitle, this.byTabIndex);
//#        //开始绘制包裹中的内容
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#        iStartY = this.iStartPointY + 22 + 7;
//#        Tools.drawPackageBox(g, this.store[this.byTabIndex - 1], this.imgArray[4], this.imgArray[0], sButton[2], iStartX, iStartY, byCurrentPage, this.byTotalPage, null, null);
//#        Tools.setColor(g, 0xFFFFFF);
//#        //绘制玩家的背包数量和空余背包数量
        //#if NOKIA_E72
//#         g.drawString(this.sArray[1], Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + Constant.DRAW_HEIGHT - 1 - Constant.FONT_SMALL_HEIGHT, 0);
//#         g.drawString(this.sArray[2], Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 232 - 15 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + Constant.DRAW_HEIGHT - 1 - Constant.FONT_SMALL_HEIGHT, 0);
//#         g.drawImage(this.imgArray[8], Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 232 - 15, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 1 - Constant.FONT_SMALL_HEIGHT + ((Constant.FONT_SMALL_HEIGHT - 12) >> 1), 0);
        //#else
//#        g.drawString(this.sArray[1], Constant.UI_START_X + 10, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 24 - Constant.FONT_SMALL_HEIGHT, 0);
//#        g.drawString(this.sArray[2], Constant.UI_START_X + Constant.DRAW_WIDTH - 31 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + Constant.DRAW_HEIGHT - 24 - Constant.FONT_SMALL_HEIGHT, 0);
//#        g.drawImage(this.imgArray[8], Constant.UI_START_X + Constant.DRAW_WIDTH - 29, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 24 - Constant.FONT_SMALL_HEIGHT + ((Constant.FONT_SMALL_HEIGHT - 12) >> 1), 0);
        //#endif
//#        //绘制玩家元宝数量
//#        //绘制选中横条
//#        if (this.bySelectIndex < 6) {
//#            Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 27, Constant.DRAW_WIDTH);
//#        } else if (this.bySelectIndex == 6) {
//#            Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 29 + 128 + Constant.FONT_SMALL_HEIGHT, Constant.DRAW_WIDTH);
//#        }
//#        //绘制物品的选中状态(最上层。防止被覆盖)
//#        if (this.bySelectIndex >= 2 && this.bySelectIndex <= 5) {
//#            if (this.shPos >= 0) {
//#                if (this.shPos % 7 == 0) {
//#                    this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#                    iStartY = this.iStartPointY + 29 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 32;
//#                } else {
//#                    this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5 + (this.shPos % 7) * 32;
//#                    iStartY = this.iStartPointY + 29 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 32;
//#                }
//#                this.store[this.byTabIndex - 1].drawSelectStyle(g, iStartX, iStartY);
//#                if (this.store[this.byTabIndex - 1].checkColumnHasGoods(this.shPos)) {
                    //#if NOKIA_E72
                    //#else
//#                    //物品的描述
//#                    Tools.drawHCycleRollingParagraph(g, this.store[this.byTabIndex - 1].getGoodsDesc(this.shPos), this.iGoodsDescHeight, 209, 50 - 7, 16, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 229) >> 1) + 10, this.iStartPointY + 196 + 7, 0xFFFFFF, -1);
                    //#endif
//#                    if (bLock) {
//#                        Tools.drawPopMenu(g, this.sOpArray, (byte) 1, Constant.FONT_CHAR_WIDTH * 4 + 4, Constant.FONT_SMALL_HEIGHT, 0x000000, 0xFFFFFF, 0x0099cc, this.byMenuIndex, iStartX, iStartY);
//#                    } else {
//#                        //物品的名称
//#                        //绘制物品的价格
//#                        Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH, this.imgArray[8], this.shTipsIngotPicStart);
//#                    }
//#                }
//#            }
//#        }
//#        switch (this.byUiState) {
//#            case 1:
//#                //绘制弹出的输入数字界面
//#                drawInputCanvas(g, this.imgArray[7], (byte) 2, 232, 68, this.imgArray[6], this.imgArray[3], this.imgArray[3], this.sArray[5], 68, 18, this.byBuyGoodsNum, this.bFlag, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 68) >> 1), this.sArray[4], this.imgArray[8]);
//#                break;
//#            case 2:
//#                break;
//#        }
        //#endif
    }

    public void clearWageStore() {
        this.store = null;
        this.sArray = null;
        this.iArray = null;
        this.items = null;
        this.sOpArray = null;
        this.byGetDataFromNet = null;
        this.sIngotTabTitle = null;
        this.sTips = null;
        this.sButton = null;
    }

    public static void drawInputCanvas(Graphics g, Image bgMask, byte byBgTileDerection, int width, int height, Image popUpFrame, Image buttonLeft, Image buttonRight, String popUpTitle, int inputWidth, int inputHeight, int inputNum, boolean bShowFlash, int startX, int startY, String totalPrice, Image ingotImg) {
        //背景遮罩层
        if (bgMask != null) {
            if (byBgTileDerection == 2) {
                Tools.drawTilePic(g, (byte) 2, Constant.UI_START_X, Constant.UI_START_Y, Constant.SCREEN_HEIGHT, bgMask, 0, 0, Constant.SCREEN_WIDTH, 10, Constant.TRANS_NONE);
            } else {
                Tools.drawTilePic(g, (byte) 1, Constant.UI_START_X, Constant.UI_START_Y, Constant.SCREEN_WIDTH, bgMask, 0, 0, 10, Constant.SCREEN_HEIGHT, Constant.TRANS_NONE);
            }
        }
        Tools.drawPopUp(g, (byte) 4, startX, startY, width, height, popUpFrame, 0x989898, buttonLeft, 0, 0, 22, 10, buttonRight, 22, 0, 21, 10, popUpTitle, null);
        //会是输入框
        g.setColor(0xFFFFFF);
        g.fillRect(startX + 30, startY + 31, inputWidth, inputHeight);
        g.setColor(0x000000);
        g.drawRect(startX + 30, startY + 31, inputWidth, inputHeight);

        //绘制用户输入的文字
        if (inputNum == -1) {
            if (bShowFlash) {
                g.drawChar('|', startX + 33, startY + 31 + ((inputHeight - Constant.FONT_SMALL_HEIGHT) >> 1), 0);
            }
        } else {
            g.drawString(String.valueOf(inputNum), startX + 33, startY + 31 + ((inputHeight - Constant.FONT_SMALL_HEIGHT) >> 1), 0);
            if (bShowFlash) {
                g.drawChar('|', startX + 33 + 4 + Constant.FONT_SMALL.stringWidth(String.valueOf(inputNum)), startY + 31 + ((inputHeight - Constant.FONT_SMALL_HEIGHT) >> 1), 0);
            }
        }
        g.drawString(totalPrice, startX + 38 + inputWidth, startY + 31 - ((inputHeight - Constant.FONT_SMALL_HEIGHT) >> 1), 0);
        g.drawImage(ingotImg, startX + 40 + inputWidth + Constant.FONT_SMALL.stringWidth(totalPrice), startY + 31 - ((inputHeight - Constant.FONT_SMALL_HEIGHT) >> 1) + ((Constant.FONT_SMALL_HEIGHT - 12) >> 1), 0);
    }

    /**************************元宝商城********************************************************/
    /**
     * 检测一下元宝是否足够
     * */
    public void setIngotGoodsState(Goods goods, short shPos) {
        if (goods.checkColumnHasGoods(shPos)) {
            //#if NOKIA_S60V5
             this.iGoodsDescHeight = Tools.getParagraphHeight(goods.getGoodsDesc(shPos), 290, Constant.FONT_SMALL_HEIGHT);
            //#else
//#            this.iGoodsDescHeight = Tools.getParagraphHeight(goods.getGoodsDesc(shPos), 209, Constant.FONT_SMALL_HEIGHT);
            //#endif
            this.sArray[3] = "售价：" + goods.getGoodsPrice(this.shPos);
            this.makeItemsTips(goods, shPos, this.sArray[3], this.imgArray[8]);
            //#if NOKIA_E72
            //#else
            this.lastSendDescTime = System.currentTimeMillis();
            this.bWaitMSGBack = false;
            //#endif
            Tools.rollIndex = 0;
            Tools.lastUpdateTime = System.currentTimeMillis();
        }
    }

    public void buyIngotStoreGoods(byte byGoodsNum) {
        this.byBuyGoodsNum = byGoodsNum;
        switch (MainLogic.getInstance().byGameState) {
            case Constant.GAME_UI_WAGE_STORE://工资商城
                if (this.lMoney < this.store[this.byTabIndex - 1].getGoodsPrice(shPos) * byGoodsNum) {
                    //#if NOKIA_S60V5
                     this.byUiState = 0;
                     MainGame.changeCanvas(MainGame.mainFrame);
                    //#endif
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的元宝余额不足!");
                } else {
                    GameBean.b_WAIT_NET_MSG_BACK = true;
                    GameBean.BY_GOODS_NUM = this.byBuyGoodsNum;
                    GameBean.STR_CDM_GOODS_KEY = this.store[this.byTabIndex - 1].getGoodsKey(this.shPos);
                    GameBean.BY_TYPE = 2;
                    //#if NOKIA_S60V5
                     this.byUiState = 0;
                     MainGame.changeCanvas(MainGame.mainFrame);
                    //#endif
                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_INGOT_BUY, Constant.SOCKET_MSG_TYPE_LOGIC);
                }
                break;
            case Constant.GAME_UI_INGOT_STORE://元宝商城
                if (bySelectIndex == 2 || bySelectIndex == 3) {
                    if (this.lMoney < this.store[this.byTabIndex - 1].getGoodsPrice(shPos) * byGoodsNum) {
                        //#if NOKIA_S60V5
                         this.byUiState = 0;
                         MainGame.changeCanvas(MainGame.mainFrame);
                        //#endif
                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的元宝余额不足!");
                    } else {
                        GameBean.b_WAIT_NET_MSG_BACK = true;
                        GameBean.BY_GOODS_NUM = this.byBuyGoodsNum;
                        GameBean.STR_CDM_GOODS_KEY = this.store[this.byTabIndex - 1].getGoodsKey(this.shPos);
                        GameBean.BY_TYPE = 1;
                        //#if NOKIA_S60V5
                         this.byUiState = 0;
                         MainGame.changeCanvas(MainGame.mainFrame);
                        //#endif
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_INGOT_BUY, Constant.SOCKET_MSG_TYPE_LOGIC);
                    }
                } else if (bySelectIndex == 5) {
                    if (this.lMoney < this.items.getGoodsPrice(shPos) * byGoodsNum) {
                        //#if NOKIA_S60V5
                         this.byUiState = 0;
                         MainGame.changeCanvas(MainGame.mainFrame);
                        //#endif
                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的元宝余额不足!");
                    } else {
                        GameBean.b_WAIT_NET_MSG_BACK = true;
                        GameBean.BY_GOODS_NUM = this.byBuyGoodsNum;
                        GameBean.STR_CDM_GOODS_KEY = this.items.getGoodsKey(this.shPos);
                        GameBean.BY_TYPE = 1;
                        //#if NOKIA_S60V5
                         this.byUiState = 0;
                         MainGame.changeCanvas(MainGame.mainFrame);
                        //#endif
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_INGOT_BUY, Constant.SOCKET_MSG_TYPE_LOGIC);
                    }
                }
                break;
            case Constant.GAME_UI_INGOT_RECORD:
                if (this.lMoney < this.items.getGoodsPrice(shPos) * byGoodsNum) {
                    //#if NOKIA_S60V5
                     this.byUiState = 0;
                     MainGame.changeCanvas(MainGame.mainFrame);
                    //#endif
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的元宝余额不足!");
                } else {
                    GameBean.b_WAIT_NET_MSG_BACK = true;
                    GameBean.BY_GOODS_NUM = this.byBuyGoodsNum;
                    GameBean.STR_CDM_GOODS_KEY = this.items.getGoodsKey(this.shPos);
                    GameBean.BY_TYPE = 1;
                    //#if NOKIA_S60V5
                     this.byUiState = 0;
                     MainGame.changeCanvas(MainGame.mainFrame);
                    //#endif
                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_INGOT_BUY, Constant.SOCKET_MSG_TYPE_LOGIC);
                }
                break;
        }
    }

    public void initIngotStore() {
        this.byState = 0;
        //界面中的位置的统一配置
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 46;
         iPositionY = this.iStartPointY + 38 + 44;
        //#else
        //#if NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 21;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 26;
        //#endif
//#        iPositionY = this.iStartPointY + 60;
        //#endif
        this.lMoney = 0;
        this.shPlayerBag = 0;
        this.shPlayerNowBag = 0;
        bLock = false;
        this.byTabIndex = 1;
        this.byTabNum = 5;
        this.store = new Goods[this.byTabNum];
        byGetDataFromNet = new byte[]{0, 0, 0, 0, 0};
//        this.sIngotTabTitle = new String[]{"1 热卖", "2 辅助", "3 装备", "4 宠物", "5 宝石", "6 技能"};
        this.sIngotTabTitle = new String[]{"1 热卖", "2 辅助", "3 装备", "4 宠物", "5 宝石"};
        this.sButton = new String[]{"确定", "返回"};
        this.bySelectIndex = 1;
        this.shPos = -1;
        this.byTotalPage = 1;
        this.byCurrentPage = 1;
        /**********************/
//        for (byte i = 0; i < 6; i++) {
//            this.store[i] = new Goods((short) 0, Constant.ITEM_COLUMN_TYPE_COMMON);
//                    this.store[i].addGoods((short) 0, true, -1, (short) -1, "下坡", (short) 1, 1181, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//                    this.store[i].addGoods((short) 1, true, -1, (short) -1, "下坡", (short) 1, 1181, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//                    this.store[i].addGoods((short) 2, true, -1, (short) -1, "下坡", (short) 1, 1181, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        }
        //        byGetDataFromNet = new byte[]{1, 1, 1, 1, 1, 1};
        //        this.items = new Goods((short) 10, Constant.ITEM_COLUMN_TYPE_COMMON);
        //        this.items.addGoods((short) 1, true, -1, (short) -1, "下坡", (short) 1, 1181, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
        //        this.items.addGoods((short) 0, true, -1, (short) -1, "下坡", (short) 1, 1181, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
        /****************************/
        this.bWaitMSGBack = false;
        this.sArray = new String[]{"元宝商城", "背包：0/0", "元宝：0", "售价:0", "合计：0", "请输入您要购买的物品数量", "限时特卖：", "等级:"};
        this.sOpArray = new String[]{"购买", "查看"};
        this.sButton = new String[]{"确定", "取消"};
        this.byCurrentPage = 1;
        this.byTotalPage = 1;
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[12];
             this.imgArray[0] = ResManager.createImage(90000041);    //箭头图片
             this.imgArray[1] = Tools.makeBlueMask();//蓝色光片
             this.imgArray[2] = ResManager.createImage(90000017);//背景图片
             this.imgArray[3] = ResManager.createImage(90000044);//白色确定
             this.imgArray[4] = ResManager.createImage(90000047);//大数字图片
             this.imgArray[5] = ResManager.createImage(90000060);//文字图片
             this.imgArray[6] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角图片
             this.imgArray[8] = ResManager.createImage(90000082);//元宝图片
             this.imgArray[9] = ResManager.createImage(90000043);//文字
             this.imgArray[10] = ResManager.createImage(90000084);//方向键
             this.imgArray[11] = ResManager.createImage(90000085);//确认
             this.imgArray[7] = ResManager.createImage(90000086);//蓝条
            //#else
//#            this.imgArray = new Image[9];
//#            this.imgArray[0] = ResManager.createImage(90000041);    //箭头图片 
//#            this.imgArray[1] = Tools.makeBlueMask();//蓝色光片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[2] = ResManager.createImage(90000017);
//# //            imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            this.imgArray[2] = ResManager.createImage(90000017);//背景图片
            //#endif
//#            this.imgArray[3] = ResManager.createImage(90000044);//白色确定
//#            this.imgArray[4] = ResManager.createImage(90000047);//大数字图片
//#            this.imgArray[5] = ResManager.createImage(90000060);//文字图片
//#            this.imgArray[6] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角图片
//#            this.imgArray[7] = Tools.makeTransparent(Constant.DRAW_WIDTH, 10, 140, 0x000000);//弹出背景遮罩层
//#            this.imgArray[8] = ResManager.createImage(90000082);//元宝图片
            //#endif
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.lastSendDescTime = System.currentTimeMillis();
    }

    public void updateIngotStore() {
        switch (this.byUiState) {
            case 0:
                if (!GameBean.b_WAIT_NET_MSG_BACK) {
                    if (!bKeypressLock) {
                        if (!bLock) {
                            //非弹出物品操作菜单
                            if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                if (this.bySelectIndex > 1) {
                                    this.bySelectIndex -= 1;
                                    switch (this.bySelectIndex) {
                                        case 1:
                                            this.shPos = -1;
                                            break;
                                        case 2:
                                            this.shPos -= 7;
                                            setIngotGoodsState(this.store[this.byTabIndex - 1], shPos);
                                            break;
                                        case 3:
                                            this.shPos = (short) ((this.byCurrentPage - 1) * 14 + 7);
                                            setIngotGoodsState(this.store[this.byTabIndex - 1], shPos);
                                            break;
                                        case 4:
                                            this.shPos = -1;
                                            break;
                                    }
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                if (this.bySelectIndex < 5) {
                                    this.bySelectIndex += 1;
                                    switch (this.bySelectIndex) {
                                        case 2:
                                            this.shPos = (short) ((this.byCurrentPage - 1) * 14);
                                            setIngotGoodsState(this.store[this.byTabIndex - 1], shPos);
                                            break;
                                        case 3:
                                            this.shPos += 7;
                                            setIngotGoodsState(this.store[this.byTabIndex - 1], shPos);
                                            break;
                                        case 4:
                                            this.shPos = -1;
                                            break;
                                        case 5:
                                            this.shPos = 0;
                                            setIngotGoodsState(this.items, shPos);
                                            break;
                                    }
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                        byTabIndex = (byte) (byTabIndex == 1 ? this.byTabNum : byTabIndex - 1);
                                        if (this.byGetDataFromNet != null && this.byGetDataFromNet[(byte) ((this.byTabIndex - 1)) - 1] == 1) {
                                            this.changeToNewTab((byte) 1);
                                        } else {
                                            openIngotStore((byte) 1, this.byTabIndex);
                                            return;
                                        }
                                        break;
                                    case 2:
                                    case 3:
                                        this.shPos = (short) (this.shPos == (this.byCurrentPage - 1) * 14 ? this.shPos : this.shPos - 1);
                                        this.bySelectIndex = (byte) ((this.shPos - (this.byCurrentPage - 1) * 14) / 7 + 2);
                                        setIngotGoodsState(this.store[this.byTabIndex - 1], shPos);
                                        break;
                                    case 4:
                                        if (this.byCurrentPage > 1) {
                                            this.byCurrentPage = (byte) (this.byCurrentPage - 1);
                                        }
                                        break;
                                    case 5:
                                        this.shPos = (short) (this.shPos == 0 ? 6 : this.shPos - 1);
                                        setIngotGoodsState(this.items, shPos);
                                        break;
                                }

                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                        byTabIndex = (byte) (byTabIndex == this.byTabNum ? 1 : byTabIndex + 1);
                                        if (this.byGetDataFromNet[this.byTabIndex - 1] == 1) {
                                            this.changeToNewTab((byte) 1);
                                        } else {
                                            openIngotStore((byte) 1, this.byTabIndex);
                                            return;
                                        }
                                        break;
                                    case 2:
                                    case 3:
                                        this.shPos = (short) (this.shPos == this.byCurrentPage * 14 - 1 ? this.shPos : this.shPos + 1);
                                        this.bySelectIndex = (byte) ((this.shPos - (this.byCurrentPage - 1) * 14) / 7 + 2);
                                        setIngotGoodsState(this.store[this.byTabIndex - 1], shPos);
                                        break;
                                    case 4:
                                        if (this.byCurrentPage < this.byTotalPage) {
                                            this.byCurrentPage = (byte) (this.byCurrentPage + 1);
                                        }
                                        break;
                                    case 5:
                                        this.shPos = (short) (this.shPos == 6 ? 0 : this.shPos + 1);
                                        setIngotGoodsState(this.items, shPos);
                                        break;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_1, false)) {
                                if (this.byGetDataFromNet[0] == 1) {
                                    byTabIndex = 1;
                                    this.changeToNewTab((byte) 1);
                                } else {
                                    openIngotStore((byte) 1, (byte) 1);
                                    return;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_2, false)) {
                                if (this.byGetDataFromNet[1] == 1) {
                                    byTabIndex = 2;
                                    this.changeToNewTab((byte) 1);
                                } else {
                                    openIngotStore((byte) 1, (byte) 2);
                                    return;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_3, false)) {
                                if (this.byGetDataFromNet[2] == 1) {
                                    byTabIndex = 3;
                                    this.changeToNewTab((byte) 1);
                                } else {
                                    openIngotStore((byte) 1, (byte) 3);
                                    return;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_4, false)) {
                                if (this.byGetDataFromNet[3] == 1) {
                                    byTabIndex = 4;
                                    this.changeToNewTab((byte) 1);
                                } else {
                                    openIngotStore((byte) 1, (byte) 4);
                                    return;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                                if (this.byGetDataFromNet[4] == 1) {
                                    byTabIndex = 5;
                                    this.changeToNewTab((byte) 1);
                                } else {
                                    openIngotStore((byte) 1, (byte) 5);
                                    return;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_6, false)) {
                                if (this.byGetDataFromNet[5] == 1) {
                                    byTabIndex = 6;
                                    this.changeToNewTab((byte) 1);
                                } else {
                                    openIngotStore((byte) 1, (byte) 6);
                                    return;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                                switch (this.bySelectIndex) {
                                    case 2:
                                    case 3:
                                        if (this.store[this.byTabIndex - 1].checkColumnHasGoods(shPos)) {
                                            this.bLock = true;
                                            this.byMenuIndex = 0;
                                        }
                                        break;
                                    case 5:
                                        if (this.items.checkColumnHasGoods(shPos)) {
                                            this.bLock = true;
                                            this.byMenuIndex = 0;
                                        }
                                        break;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                Tools.openRoamMenu(false, (byte) 1, (byte) 1, 1);
                            } else {
                                if ((this.bySelectIndex >= 2 && this.bySelectIndex <= 3) || this.bySelectIndex == 5) {
                                    //#if NOKIA_E72
                                    //#else
                                    this.getGoodsDescFromNet();
                                    //#endif
                                }
                            }
                        } else {
                            if (!((this.bySelectIndex >= 2 && this.bySelectIndex <= 3) || this.bySelectIndex == 5)) {
                                this.bLock = false;
                                return;
                            } else {
                                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                    this.bLock = false;
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                    this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 0);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                    this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 1);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                                    this.bLock = false;
                                    switch (this.byMenuIndex) {
                                        case 0:
                                            //#if NOKIA_S60V5
                                             MainLogic.getInstance().inputInterFace.setInputInterFace((byte) 1, "请输入要购买的物品数量:");
                                             MainLogic.getInstance().inputInterFace.commonInput.setString(String.valueOf(1));
                                             MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
                                            //#else
//#                                            this.byUiState = 1;
//#                                            this.sArray[4] = "合计：0";
//#                                            this.byBuyGoodsNum = 0;
                                            //#endif
                                            break;
                                        case 1:
                                            //查看道具界面
                                            switch (this.bySelectIndex) {
                                                case 2:
                                                case 3:
                                                    GameBean.b_WAIT_NET_MSG_BACK = true;
                                                    MainLogic.getInstance().uiInterFace.sysMessage.checkStoreItem(this.store[this.byTabIndex - 1].getGoodsAlias(this.shPos), this.store[this.byTabIndex - 1].getGoodsColor(this.shPos), this.store[this.byTabIndex - 1].icon[this.shPos], this.store[this.byTabIndex - 1].getGoodsKey(this.shPos));
                                                    break;
                                                case 5:
                                                    GameBean.b_WAIT_NET_MSG_BACK = true;
                                                    MainLogic.getInstance().uiInterFace.sysMessage.checkStoreItem(this.items.getGoodsAlias(this.shPos), this.items.getGoodsColor(this.shPos), this.items.icon[this.shPos], this.items.getGoodsKey(this.shPos));
                                                    break;
                                            }
                                            break;
                                        case 2:
                                            //收藏道具
                                            break;
                                        case 3:
                                            //我的收藏
                                            break;
                                    }
                                }
                            }
                        }
                    } else {
                        if (this.byState == 1 || this.byState == 2) {
                            iPositionY = Tools.updateLinePos(this.iArray, iPositionY);
                            if (this.iArray == null || this.iArray[1] == 0) {
                                this.byState = 0;
                                this.bKeypressLock = false;
                            }
                        }
                        MainCanvas.clearInput();
                    }
                }
                break;
            case 1:
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                    this.byUiState = 0;
                    if (this.byBuyGoodsNum < 1 || this.byBuyGoodsNum > 99) {
                        this.byBuyGoodsNum = 1;
                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您输入的数量不正确!");
                    } else {
                        //发送购买消息
                        switch (this.bySelectIndex) {
                            case 2:
                            case 3:
                            case 5:
                                this.buyIngotStoreGoods(byBuyGoodsNum);
                                break;
                        }
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                    this.byUiState = 0;
                    this.byBuyGoodsNum = 0;
                } else {
                    this.byBuyGoodsNum = (byte) Tools.updateInputCanvas(this.byBuyGoodsNum, 99);
                    if (this.byBuyGoodsNum > -1) {
                        switch (this.bySelectIndex) {
                            case 2:
                            case 3:
                                this.sArray[4] = "合计：" + this.store[this.byTabIndex - 1].getGoodsPrice(this.shPos) * this.byBuyGoodsNum;
                                break;
                            case 5:
                                this.sArray[4] = "合计：" + this.items.getGoodsPrice(this.shPos) * this.byBuyGoodsNum;
                                break;
                        }
                    } else {
                        this.sArray[4] = "合计：0";
                    }
                }
                this.bFlag = this.bFlag ? false : true;
                break;
            case 2:
                break;
        }
        MainCanvas.clearInput();
    }

    public void drawIngotStore(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[10], this.imgArray[11], this.imgArray[7], this.imgArray[9], sArray[0]);
         //绘制包裹栏和任务栏的背景
         drawIngotPackageBg(g, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1), this.iStartPointY, this.imgArray[6], this.sIngotTabTitle, this.byTabIndex);
         //开始绘制包裹中的内容
         iStartY = this.iStartPointY + 38;
         //绘制商城商品
         for (byte i = 0; i < 14; i++) {
             //物品放置的索引位置
             if (i % 7 == 0) {
                 iStartX = Constant.UI_START_X + 28;
             }
             if (this.store != null && this.store[this.byTabIndex - 1] != null) {
                 this.store[this.byTabIndex - 1].drawGoods(g, iStartX, iStartY, (short) ((this.byCurrentPage - 1) * 14 + i));
             }
             //绘制的格子
             if (i % 7 == 6) {
                 iStartY = iStartY + 44;
             }
             iStartX = iStartX + 44;
         }
         //绘制翻页
         Tools.drawPage(g, this.byTotalPage, this.byCurrentPage, this.imgArray[4], this.imgArray[0], Constant.UI_START_X + 333 - Tools.getPageStrWidth(this.byTotalPage, this.byCurrentPage), iStartY + ((Constant.FONT_SMALL_HEIGHT - 9) >> 1));
         //绘制限时特卖
         iStartX = Constant.UI_START_X + 28;
         iStartY = iStartY + 44;
         Tools.drawShadowString(g, (byte) 1, this.sArray[6], iStartX + 3, iStartY - Constant.FONT_SMALL_HEIGHT - 2, 0x0099CC, 0x000000);
         for (byte i = 0; i < 7; i++) {
             this.items.drawGoods(g, iStartX, iStartY, i);
             iStartX += 44;
         }
         //绘制玩家的背包数量和空余背包数量
         Tools.setColor(g, 0xFFFFFF);
         g.drawString(this.sArray[1], Constant.UI_START_X + 28, Constant.UI_START_Y + 395, 0);
         g.drawString(this.sArray[2], Constant.UI_START_X + Constant.DRAW_WIDTH - 51 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + 395, 0);
         g.drawImage(this.imgArray[8], Constant.UI_START_X + Constant.DRAW_WIDTH - 48, Constant.UI_START_Y + 395 + ((Constant.FONT_SMALL_HEIGHT - 12) >> 1), 0);
 
         //绘制玩家元宝数量
         //绘制选中横条
         switch (this.bySelectIndex) {
             case 1:
             case 2:
             case 3:
                 Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 38, Constant.DRAW_WIDTH);
                 break;
             case 4:
                 Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 38 + 88 + 15, Constant.DRAW_WIDTH);
                 break;
         }
 
         //绘制物品的选中状态(最上层。防止被覆盖)
         if ((this.bySelectIndex >= 2 && this.bySelectIndex <= 3) || this.bySelectIndex == 5) {
             switch (this.bySelectIndex) {
                 case 2:
                 case 3:
                     if (this.shPos >= 0) {
                         if (this.shPos % 7 == 0) {
                             this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1) + 6;
                             iStartY = this.iStartPointY + 38 + ((this.shPos - (this.byCurrentPage - 1) * 14) / 7) * 44;
                         } else {
                             this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1) + 6 + (this.shPos % 7) * 44;
                             iStartY = this.iStartPointY + 38 + ((this.shPos - (this.byCurrentPage - 1) * 14) / 7) * 44;
                         }
                         this.store[this.byTabIndex - 1].drawSelectStyle(g, iStartX, iStartY);
                         if (this.store[this.byTabIndex - 1].checkColumnHasGoods(this.shPos)) {
                             //物品的描述
                             Tools.drawHCycleRollingParagraph(g, this.store[this.byTabIndex - 1].getGoodsDesc(this.shPos), this.iGoodsDescHeight, 290, 60, Constant.FONT_SMALL_HEIGHT, Constant.UI_START_X + 28, this.iStartPointY + 275, 0xFFFFFF, -1);
                             if (bLock) {
                                 this.items.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, iStartX, iStartY);
                             } else {
                                 Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH, this.imgArray[8], this.shTipsIngotPicStart);
                             }
                         }
                     }
                     break;
                 case 5:
                     if (this.shPos >= 0) {
                         iStartX = Constant.UI_START_X + 28 + this.shPos * 44;
                         iStartY = this.iStartPointY + 38 + 44 * 3;
                         this.items.drawSelectStyle(g, iStartX, iStartY);
                         if (this.items.checkColumnHasGoods(this.shPos)) {
                             Tools.drawHCycleRollingParagraph(g, this.items.getGoodsDesc(this.shPos), this.iGoodsDescHeight, 290, 60, Constant.FONT_SMALL_HEIGHT, Constant.UI_START_X + 28, this.iStartPointY + 275, 0xFFFFFF, -1);
                             if (bLock) {
                                 Tools.drawPopMenu(g, this.sOpArray, (byte) 1, Constant.FONT_CHAR_WIDTH * 4 + 4, Constant.FONT_SMALL_HEIGHT, 0x000000, 0xFFFFFF, 0x0099cc, this.byMenuIndex, iStartX, iStartY);
                             } else {
                                 Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH, this.imgArray[8], this.shTipsIngotPicStart);
                             }
                         }
                     }
                     break;
             }
 
         }
        //#else
        //#if NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[2], this.sButton[0], this.sButton[1], sArray[0]);
        //#else
//#        Tools.drawFrame(g, this.imgArray[2], this.imgArray[1], this.sButton[0], this.sButton[1], sArray[0]);
        //#endif
//#        //绘制包裹栏和任务栏的背景
//#        drawIngotPackageBg(g, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), this.iStartPointY, this.imgArray[6], this.sIngotTabTitle, this.byTabIndex);
//#        //开始绘制包裹中的内容
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#        iStartY = this.iStartPointY + 29;
//#        //绘制商城商品
//#        for (byte i = 0; i < 14; i++) {
//#            //物品放置的索引位置
//#            if (i % 7 == 0) {
//#                iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#            }
//#            if (this.store != null && this.store[this.byTabIndex - 1] != null) {
//#                this.store[this.byTabIndex - 1].drawGoods(g, iStartX, iStartY, (short) ((this.byCurrentPage - 1) * 14 + i));
//#            }
//#            //绘制的格子
//#            if (i % 7 == 6) {
//#                iStartY = iStartY + 32;
//#            }
//#            iStartX = iStartX + 32;
//#        }
//#        //绘制翻页
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#        Tools.drawPage(g, this.byTotalPage, this.byCurrentPage, this.imgArray[4], this.imgArray[0], iStartX + 222 - Tools.getPageStrWidth(this.byTotalPage, this.byCurrentPage), iStartY + ((Constant.FONT_SMALL_HEIGHT - 9) >> 1) + 2);
//#        //绘制限时特卖
//#        iStartY = this.iStartPointY + 29 + 32 * 3 + 18;
//#        Tools.drawShadowString(g, (byte) 1, this.sArray[6], iStartX + 3, iStartY - Constant.FONT_SMALL_HEIGHT - 2, 0x0099CC, 0x000000);
//#        for (byte i = 0; i < 7; i++) {
//#            this.items.drawGoods(g, iStartX, iStartY, i);
//#            iStartX += 32;
//#        }
//#
//#        //绘制玩家的背包数量和空余背包数量
//#        Tools.setColor(g, 0xFFFFFF);
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1);
        //#if NOKIA_E72
//#         g.drawString(this.sArray[1], iStartX, Constant.UI_START_Y + Constant.DRAW_HEIGHT - Constant.FONT_SMALL_HEIGHT - 1, 0);
//#         g.drawString(this.sArray[2], iStartX + 232 - 20 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + Constant.DRAW_HEIGHT - Constant.FONT_SMALL_HEIGHT - 1, 0);
//#         g.drawImage(this.imgArray[8], iStartX + 232 - 18, Constant.UI_START_Y + Constant.DRAW_HEIGHT - Constant.FONT_SMALL_HEIGHT - 1 + ((Constant.FONT_SMALL_HEIGHT - 12) >> 1), 0);
        //#else
//#        g.drawString(this.sArray[1], Constant.UI_START_X + 10, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 24 - Constant.FONT_SMALL_HEIGHT, 0);
//#        g.drawString(this.sArray[2], Constant.UI_START_X + Constant.DRAW_WIDTH - 31 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + Constant.DRAW_HEIGHT - 24 - Constant.FONT_SMALL_HEIGHT, 0);
//#        g.drawImage(this.imgArray[8], Constant.UI_START_X + Constant.DRAW_WIDTH - 29, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 24 - Constant.FONT_SMALL_HEIGHT + ((Constant.FONT_SMALL_HEIGHT - 12) >> 1), 0);
        //#endif
//#        //绘制玩家元宝数量
//#        //绘制选中横条
//#        switch (this.bySelectIndex) {
//#            case 1:
//#            case 2:
//#            case 3:
//#                Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 29, Constant.DRAW_WIDTH);
//#                break;
//#            case 4:
//#                Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 29 + 62 + 15, Constant.DRAW_WIDTH);
//#                break;
//#        }
//#
//#        //绘制物品的选中状态(最上层。防止被覆盖)
//#        if ((this.bySelectIndex >= 2 && this.bySelectIndex <= 3) || this.bySelectIndex == 5) {
//#            switch (this.bySelectIndex) {
//#                case 2:
//#                case 3:
//#                    if (this.shPos >= 0) {
//#                        if (this.shPos % 7 == 0) {
//#                            this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#                            iStartY = this.iStartPointY + 29 + ((this.shPos - (this.byCurrentPage - 1) * 14) / 7) * 32;
//#                        } else {
//#                            this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5 + (this.shPos % 7) * 32;
//#                            iStartY = this.iStartPointY + 29 + ((this.shPos - (this.byCurrentPage - 1) * 14) / 7) * 32;
//#                        }
//#                        this.store[this.byTabIndex - 1].drawSelectStyle(g, iStartX, iStartY);
//#                        if (this.store[this.byTabIndex - 1].checkColumnHasGoods(this.shPos)) {
//#                            //物品的描述
                            //#if NOKIA_E72
                            //#else
//#                            Tools.drawHCycleRollingParagraph(g, this.store[this.byTabIndex - 1].getGoodsDesc(this.shPos), this.iGoodsDescHeight, 209, 50 - 7, 16, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 229) >> 1) + 10, this.iStartPointY + 196 + 7, 0xFFFFFF, -1);
                            //#endif
//#                            if (bLock) {
//#                                Tools.drawPopMenu(g, this.sOpArray, (byte) 1, Constant.FONT_CHAR_WIDTH * 4 + 4, Constant.FONT_SMALL_HEIGHT, 0x000000, 0xFFFFFF, 0x0099cc, this.byMenuIndex, iStartX, iStartY);
//#                            } else {
//#                                Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH, this.imgArray[8], this.shTipsIngotPicStart);
//#                            }
//#                        }
//#                    }
//#                    break;
//#                case 5:
//#                    if (this.shPos >= 0) {
//#                        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5 + this.shPos * 32;
//#                        iStartY = this.iStartPointY + 29 + 32 * 3 + 18;
//#                        this.items.drawSelectStyle(g, iStartX, iStartY);
//#                        if (this.items.checkColumnHasGoods(this.shPos)) {
//#                            //物品的描述
                            //#if NOKIA_E72
                            //#else
//#                            Tools.drawHCycleRollingParagraph(g, this.items.getGoodsDesc(this.shPos), this.iGoodsDescHeight, 209, 50 - 7, 16, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 229) >> 1) + 10, this.iStartPointY + 196 + 7, 0xFFFFFF, -1);
                            //#endif
//#                            if (bLock) {
//#                                Tools.drawPopMenu(g, this.sOpArray, (byte) 1, Constant.FONT_CHAR_WIDTH * 4 + 4, Constant.FONT_SMALL_HEIGHT, 0x000000, 0xFFFFFF, 0x0099cc, this.byMenuIndex, iStartX, iStartY);
//#                            } else {
//#                                //绘制物品的价格
//#                                Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH, this.imgArray[8], this.shTipsIngotPicStart);
//#                            }
//#                        }
//#                    }
//#                    break;
//#            }
//#
//#        }
//#        switch (this.byUiState) {
//#            case 1:
//#                //绘制弹出的输入数字界面
//#                drawInputCanvas(g, this.imgArray[7], (byte) 2, 232, 68, this.imgArray[6], this.imgArray[3], this.imgArray[3], this.sArray[5], 68, 18, this.byBuyGoodsNum, this.bFlag, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 68) >> 1), this.sArray[4], this.imgArray[8]);
//#                break;
//#            case 2:
//#                break;
//#        }
        //#endif
    }

    public void clearIngotStore() {
        this.store = null;
        this.sArray = null;
        this.iArray = null;
        this.items = null;
        this.sOpArray = null;
        this.byGetDataFromNet = null;
        this.sIngotTabTitle = null;
        this.sTips = null;
        this.sButton = null;
    }

    public void drawIngotPackageBg(Graphics g, int startX, int startY, Image boxImg, String[] tabTitle, byte byTabIndex) {
        //绘制公共部分的边线和中间的填充部分
        //#if NOKIA_S60V5
         //左面的
         Tools.drawTilePic(g, (byte) 2, startX, startY + 34, 270 - 34 - 13, boxImg, 14, 0, 13, 13, Constant.TRANS_NONE);
         //右面的
         Tools.drawTilePic(g, (byte) 2, startX + 318 - 13, startY + 34, 270 - 34 - 13, boxImg, 14, 0, 13, 13, Constant.TRANS_ROT180);
         //下面的
         Tools.drawTilePic(g, (byte) 1, startX + 13, startY + 270 - 13, 318 - 26, boxImg, 14, 14, 13, 13, Constant.TRANS_NONE);//下面
         //底部
         g.drawRegion(boxImg, 0, 14, 13, 13, Constant.TRANS_NONE, startX, startY + 270 - 13, 0); //左下角
         g.drawRegion(boxImg, 0, 14, 13, 13, Constant.TRANS_ROT270, startX + 318 - 13, startY + 270 - 13, 0); //右下角
         //填充中间的部分呢
         g.setColor(0x9c9c9c);
         g.fillRect(startX + 13, startY + 34, 292, 224);
         this.drawOverlayTab(g, 318, tabTitle.length, byTabIndex, 34, 102, boxImg, tabTitle, startX, startY);
        //#else
//#        //左面的
//#        Tools.drawTilePic(g, (byte) 2, startX, startY + 28, 165, boxImg, 14, 0, 7, 7, Constant.TRANS_NONE);
//#        //右面的
//#        Tools.drawTilePic(g, (byte) 2, startX + 225, startY + 28, 165, boxImg, 14, 7, 7, 7, Constant.TRANS_NONE);
//#        //下面的
//#        Tools.drawTilePic(g, (byte) 1, startX + 7, startY + 193, 218, boxImg, 21, 7, 6, 7, Constant.TRANS_NONE);
//#        //底部
//#        g.drawRegion(boxImg, 0, 7, 7, 7, Constant.TRANS_NONE, startX, startY + 193, 0); //左下角
//#        g.drawRegion(boxImg, 7, 7, 7, 7, Constant.TRANS_NONE, startX + 225, startY + 186 + 7, 0); //右下角
//#        //填充中间的部分呢
//#        g.setColor(0x989898);
//#        g.fillRect(startX + 7, startY + 21 + 7, 218, 165);
//#        this.drawOverlayTab(g, 232, tabTitle.length, byTabIndex, 28, 82, boxImg, tabTitle, startX, startY);
        //#endif
    }

    /**
     * 绘制覆盖的标签页
     */
    public void drawOverlayTab(Graphics g, int totalWidth, int tabNum, int cTabNum, int tabHeight, int tabWidth, Image borderFrame, String[] tabTitle, int startX, int startY) {
        int overlayWidth = (totalWidth - tabWidth) / (tabNum - 1);
        //#if NOKIA_S60V5
         g.setColor(0x9c9c9c);
         g.fillRect(startX + 13, startY + 13, 318 - 26, tabHeight - 13);
         cTabNum -= 1;
         for (byte i = 0; i < tabNum; i++) {
             if (i < cTabNum) {
                 g.drawRegion(borderFrame, 0, 0, 13, 13, Constant.TRANS_NONE, startX + i * overlayWidth, startY, 0); //左上角
                 Tools.drawTilePic(g, (byte) 2, startX + i * overlayWidth, startY + 13, tabHeight - 13, borderFrame, 14, 0, 13, 13, Constant.TRANS_NONE);//左边
                 Tools.drawTilePic(g, (byte) 1, startX + i * overlayWidth + 13, startY, overlayWidth, borderFrame, 28, 0, 13, 13, Constant.TRANS_NONE);//上边
                 //绘制标题
                 g.setClip(startX + i * overlayWidth, startY, overlayWidth, tabHeight);
                 Tools.drawShadowString(g, (byte) 1, tabTitle[i], startX + i * overlayWidth + ((tabWidth - Constant.FONT_SMALL.stringWidth(tabTitle[i])) >> 1), startY + ((tabHeight - Constant.FONT_SMALL_HEIGHT) >> 1), 0xFFFFFF, 0xcccccc);
                 g.setClip(Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
             } else if (i == cTabNum) {
                 continue;
             } else if (i > cTabNum) {
                 for (int j = tabNum - 1; j >= i; j--) {
                     //右上角
                     g.drawRegion(borderFrame, 0, 0, 13, 13, Constant.TRANS_ROT90, startX + j * overlayWidth + tabWidth - 13, startY, 0);//右上角
                     Tools.drawTilePic(g, (byte) 2, startX + j * overlayWidth + tabWidth - 13, startY + 13, tabHeight - 13, borderFrame, 14, 0, 13, 13, Constant.TRANS_ROT180);//右边
                     Tools.drawTilePic(g, (byte) 1, startX + (j - 1) * overlayWidth + tabWidth - 13, startY, overlayWidth, borderFrame, 28, 0, 13, 13, Constant.TRANS_NONE);//上边
                     g.setClip(startX + (j - 1) * overlayWidth + tabWidth, startY, overlayWidth, tabHeight);
                     Tools.drawShadowString(g, (byte) 1, tabTitle[j], startX + j * overlayWidth + ((tabWidth - Constant.FONT_SMALL.stringWidth(tabTitle[j])) >> 1), startY + ((tabHeight - Constant.FONT_SMALL_HEIGHT) >> 1), 0xFFFFFF, 0xcccccc);
                     g.setClip(Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
                 }
                 break;
             }
         }
         //绘制当前的页面
         startX = startX + cTabNum * overlayWidth;
         //左上角
         g.drawRegion(borderFrame, 0, 0, 13, 13, Constant.TRANS_NONE, startX, startY, 0); //左上角
         //右上角
         g.drawRegion(borderFrame, 0, 0, 13, 13, Constant.TRANS_ROT90, startX + tabWidth - 13, startY, 0);//右上角
         //左
         Tools.drawTilePic(g, (byte) 2, startX, startY + 13, 34 - 13, borderFrame, 14, 0, 13, 13, Constant.TRANS_NONE);
         //右
         Tools.drawTilePic(g, (byte) 2, startX + tabWidth - 13, startY + 13, 34 - 13, borderFrame, 14, 0, 13, 13, Constant.TRANS_ROT180);
         //上
         Tools.drawTilePic(g, (byte) 1, startX + 13, startY, tabWidth - 26, borderFrame, 14, 14, 13, 13, Constant.TRANS_NONE);
         g.drawRegion(borderFrame, 42, 0, 10, 24, Constant.TRANS_NONE, startX + 6, startY + 5, 0); //头
         g.drawRegion(borderFrame, 42, 0, 10, 24, Constant.TRANS_ROT180, startX + tabWidth - 16, startY + 5, 0); //尾
         Tools.drawTilePic(g, (byte) 1, startX + 16, startY + 5, tabWidth - 32, borderFrame, 53, 0, 10, 24, Constant.TRANS_NONE);//中间
 
         Tools.drawShadowString(g, (byte) 2, tabTitle[cTabNum], startX + ((tabWidth - Constant.FONT_SMALL.stringWidth(tabTitle[cTabNum])) >> 1), startY + ((tabHeight - Constant.FONT_SMALL_HEIGHT) >> 1), 0x00CCFF, 0x000000);
         g.setColor(0x000000);
         g.drawLine(startX + 1, startY + tabHeight - 2, startX + 1 + tabWidth - 2, startY + tabHeight - 2);
        //#else
//#        g.setColor(0x989898);
//#        g.fillRect(startX + 7, startY + 7, 232 - 14, tabHeight - 7);
//#        cTabNum -= 1;
//#        for (byte i = 0; i < tabNum; i++) {
//#            if (i < cTabNum) {
//#                g.drawRegion(borderFrame, 0, 0, 7, 7, Constant.TRANS_NONE, startX + i * overlayWidth, startY, 0); //左上角
//#                Tools.drawTilePic(g, (byte) 2, startX + i * overlayWidth, startY + 7, tabHeight - 7, borderFrame, 14, 0, 7, 7, Constant.TRANS_NONE);//左边
//#                Tools.drawTilePic(g, (byte) 1, startX + i * overlayWidth + 7, startY, overlayWidth, borderFrame, 21, 0, 6, 7, Constant.TRANS_NONE);//上边
//#                //绘制标题
//#                g.setClip(startX + i * overlayWidth, startY, overlayWidth, tabHeight);
//#                Tools.drawShadowString(g, (byte) 1, tabTitle[i], startX + i * overlayWidth + ((tabWidth - Constant.FONT_SMALL.stringWidth(tabTitle[i])) >> 1), startY + ((tabHeight - Constant.FONT_SMALL_HEIGHT) >> 1), 0xFFFFFF, 0xcccccc);
//#                g.setClip(Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
//#            } else if (i == cTabNum) {
//#                continue;
//#            } else if (i > cTabNum) {
//#                for (int j = tabNum - 1; j >= i; j--) {
//#                    //右上角
//#                    g.drawRegion(borderFrame, 7, 0, 7, 7, Constant.TRANS_NONE, startX + j * overlayWidth + tabWidth - 7, startY, 0);//右上角
//#                    Tools.drawTilePic(g, (byte) 2, startX + j * overlayWidth + tabWidth - 7, startY + 7, tabHeight - 7, borderFrame, 14, 7, 7, 7, Constant.TRANS_NONE);//右边
//#                    Tools.drawTilePic(g, (byte) 1, startX + (j - 1) * overlayWidth + tabWidth - 7, startY, overlayWidth, borderFrame, 21, 0, 6, 7, Constant.TRANS_NONE);//上边
//#                    g.setClip(startX + (j - 1) * overlayWidth + tabWidth, startY, overlayWidth, tabHeight);
//#                    Tools.drawShadowString(g, (byte) 1, tabTitle[j], startX + j * overlayWidth + ((tabWidth - Constant.FONT_SMALL.stringWidth(tabTitle[j])) >> 1), startY + ((tabHeight - Constant.FONT_SMALL_HEIGHT) >> 1), 0xFFFFFF, 0xcccccc);
//#                    g.setClip(Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
//#                }
//#                break;
//#            }
//#        }
//#        //绘制当前的页面
//#        startX = startX + cTabNum * overlayWidth;
//#        //左上角
//#        g.drawRegion(borderFrame, 0, 0, 7, 7, Constant.TRANS_NONE, startX, startY, 0); //左上角
//#        //右上角
//#        g.drawRegion(borderFrame, 7, 0, 7, 7, Constant.TRANS_NONE, startX + tabWidth - 7, startY, 0);//右上角
//#        //左
//#        Tools.drawTilePic(g, (byte) 2, startX, startY + 7, 14 + 7, borderFrame, 14, 0, 7, 7, Constant.TRANS_NONE);
//#        //右
//#        Tools.drawTilePic(g, (byte) 2, startX + tabWidth - 7, startY + 7, 14 + 7, borderFrame, 14, 7, 7, 7, Constant.TRANS_NONE);
//#        //上
//#        Tools.drawTilePic(g, (byte) 1, startX + 7, startY, tabWidth - 14, borderFrame, 21, 0, 6, 7, Constant.TRANS_NONE);
//#        g.drawRegion(borderFrame, 27, 0, 5, 14, Constant.TRANS_NONE, startX + 3, startY + ((tabHeight - 14) >> 1), 0); //头
//#        g.drawRegion(borderFrame, 27, 0, 5, 14, Constant.TRANS_ROT180, startX + tabWidth - 8, startY + ((tabHeight - 14) >> 1), 0); //尾
//#        Tools.drawTilePic(g, (byte) 1, startX + 8, startY + ((tabHeight - 14) >> 1), tabWidth - 16, borderFrame, 31, 0, 1, 14, Constant.TRANS_NONE);
//#        Tools.drawShadowString(g, (byte) 2, tabTitle[cTabNum], startX + ((tabWidth - Constant.FONT_SMALL.stringWidth(tabTitle[cTabNum])) >> 1), startY + ((tabHeight - Constant.FONT_SMALL_HEIGHT) >> 1), 0x00CCFF, 0x000000);
//#        g.setColor(0x000000);
//#        g.drawLine(startX + 1, startY + tabHeight - 2, startX + 1 + tabWidth - 2, startY + tabHeight - 2);
        //#endif
    }

    /***************************我的元宝购买和收藏记录***********************************************************************************/
    public void openIngotRecord(byte byIngotRecordType, short shPlayerBag, short shPlayerNowBag, int ingotNum) {
        this.byStoreType = byIngotRecordType;
        this.shPlayerBag = shPlayerBag;
        this.shPlayerNowBag = shPlayerNowBag;
        this.lMoney = ingotNum;
        this.byStoreType = 1;
        MainLogic.getInstance().pushState(Constant.GAME_UI_INGOT_RECORD, true);
    }

    public void initIngotRecord() {
        /**888888888888888*/
//        this.myItems = new Goods((short) 18, Constant.ITEM_COLUMN_TYPE_COMMON);
//        this.myItems.addGoods((short) 0, true, -1, (short) -1, "据钴棒", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.myItems.addGoods((short) 1, true, -1, (short) -1, "据e钴棒", (short) 1, 1197, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 11, (byte) 99, "10031");
//        this.myItems.addGoods((short) 2, true, -1, (short) -1, "据ee钴棒", (short) 1, 1198, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 81, (byte) 99, "10031");
//        this.myItems.addGoods((short) 3, true, -1, (short) -1, "据钴棒e", (short) 1, 1199, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 112, (byte) 99, "10031");
//        this.myItems.addGoods((short) 4, true, -1, (short) -1, "据e钴棒", (short) 1, 1194, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 8, (byte) 99, "10031");
//        this.myItems.addGoods((short) 5, true, -1, (short) -1, "据钴棒", (short) 1, 1193, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 89, (byte) 99, "10031");
//        this.items = new Goods((short) 7, Constant.ITEM_COLUMN_TYPE_COMMON);
//        this.items.addGoods((short) 0, true, -1, (short) -1, "据钴棒", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
        /****************************/
        this.sArray = new String[]{"购买记录", "背包：" + shPlayerNowBag + "/" + shPlayerBag, "元宝：" + lMoney, "售价:0", "合计：0", "请输入您要购买的物品数量", "限时特卖：", "等级:"};
        this.sOpArray = new String[]{"确定购买", "查看道具"};
        this.sButton = new String[]{"确定", "返回"};
        this.byState = 0;
        //界面中的位置的统一配置
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 46;
         iPositionY = this.iStartPointY + 38 + 44;
        //#else
        //#if NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 21;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 26;
        //#endif
//#        iPositionY = this.iStartPointY + 68;
        //#endif
        bLock = false;
        this.bWaitMSGBack = false;
        this.bySubSelectIndex = 1;
        this.shPos = 0;
        this.bySelectIndex = 1;
        this.byTotalPage = (byte) Math.max(Tools.ceil(this.myItems.getMaxColumNum(), 14), 1);

        this.byCurrentPage = 1;
        this.iGoodsDescHeight = 0;
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[12];
             this.imgArray[0] = ResManager.createImage(90000041);    //箭头图片
             this.imgArray[1] = Tools.makeBlueMask();//蓝色光片
             this.imgArray[2] = ResManager.createImage(90000017);//背景图片
             this.imgArray[3] = ResManager.createImage(90000041);//白色确定
             this.imgArray[4] = ResManager.createImage(90000047);//大数字图片
             this.imgArray[5] = ResManager.createImage(90000060);//文字图片
             this.imgArray[6] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角图片
             this.imgArray[7] = ResManager.createImage(90000086);//蓝条
             this.imgArray[8] = ResManager.createImage(90000082);//元宝图片
             this.imgArray[9] = ResManager.createImage(90000043);//文字
             this.imgArray[10] = ResManager.createImage(90000084);//方向键
             this.imgArray[11] = ResManager.createImage(90000085);//确认
            //#else
//#            this.imgArray = new Image[9];
//#            this.imgArray[0] = ResManager.createImage(90000041);    //箭头图片 
//#            this.imgArray[1] = Tools.makeBlueMask();//蓝色光片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[2] = ResManager.createImage(90000017);
//# //            imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            this.imgArray[2] = ResManager.createImage(90000017);//背景图片
            //#endif
//#            this.imgArray[3] = ResManager.createImage(90000044);//白色确定
//#            this.imgArray[4] = ResManager.createImage(90000047);//大数字图片
//#            this.imgArray[5] = ResManager.createImage(90000060);//文字图片
//#            this.imgArray[6] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角图片
//#            this.imgArray[7] = Tools.makeTransparent(Constant.DRAW_WIDTH, 10, 140, 0x000000);//弹出背景遮罩层
//#            this.imgArray[8] = ResManager.createImage(90000082);//元宝图片
            //#endif
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.setIngotGoodsState(myItems, shPos);
    }

    /**
     * 更新收藏或是购买记录逻辑
     */
    public void updateIngotRecord() {
        switch (this.byUiState) {
            case 0:
                if (!GameBean.b_WAIT_NET_MSG_BACK) {
                    if (!bKeypressLock) {
                        if (!bLock) {
                            //非弹出物品操作菜单
                            if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                if (this.bySelectIndex > 1) {
                                    this.bySelectIndex -= 1;
                                    switch (this.bySelectIndex) {
                                        case 1:
                                            this.shPos -= 7;
                                            this.setIngotGoodsState(myItems, shPos);
                                            break;
                                        case 2:
                                            this.shPos = (short) ((this.byCurrentPage - 1) * 14 + 7);
                                            this.setIngotGoodsState(myItems, shPos);
                                            break;
                                        case 3:
                                            this.shPos -= 1;
                                            break;
                                    }
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                if (this.bySelectIndex < 4) {
                                    this.bySelectIndex += 1;
                                    switch (this.bySelectIndex) {
                                        case 2:
                                            this.shPos += 7;
                                            this.setIngotGoodsState(myItems, shPos);
                                            break;
                                        case 3:
                                            this.shPos = -1;
                                            break;
                                        case 4:
                                            this.shPos = 0;
                                            this.setIngotGoodsState(items, shPos);
                                            break;
                                    }
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                    case 2:
                                        this.shPos = (short) (this.shPos == (this.byCurrentPage - 1) * 14 ? this.shPos : this.shPos - 1);
                                        this.bySelectIndex = (byte) ((this.shPos - (this.byCurrentPage - 1) * 14) / 7 + 1);
                                        this.setIngotGoodsState(myItems, shPos);
                                        break;
                                    case 3:
                                        if (this.byCurrentPage > 1) {
                                            this.byCurrentPage = (byte) (this.byCurrentPage - 1);
                                        }
                                        break;
                                    case 4:
                                        this.shPos = (short) (this.shPos == 0 ? 6 : this.shPos - 1);
                                        this.setIngotGoodsState(items, shPos);
                                        break;
                                }

                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                    case 2:
                                        this.shPos = (short) (this.shPos == this.byCurrentPage * 14 - 1 ? this.shPos : this.shPos + 1);
                                        this.bySelectIndex = (byte) ((this.shPos - (this.byCurrentPage - 1) * 14) / 7 + 1);
                                        this.setIngotGoodsState(myItems, shPos);
                                        break;
                                    case 3:
                                        if (this.byCurrentPage < this.byTotalPage) {
                                            this.byCurrentPage = (byte) (this.byCurrentPage + 1);
                                        }
                                        break;
                                    case 4:
                                        this.shPos = (short) (this.shPos == 6 ? 0 : this.shPos + 1);
                                        this.setIngotGoodsState(items, shPos);
                                        break;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_0, false)) {
                                this.bySelectIndex = 5;
                                this.byCurrentPage = (byte) (this.byCurrentPage == this.byTotalPage ? 1 : this.byCurrentPage + 1);
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                    case 2:
                                        if (this.myItems.checkColumnHasGoods(shPos)) {
                                            this.bLock = true;
                                            this.byMenuIndex = 0;
                                            this.sOpArray = new String[]{"查看"};
                                        }
                                        break;
                                    case 4:
                                        if (this.items.checkColumnHasGoods(shPos)) {
                                            this.bLock = true;
                                            this.byMenuIndex = 0;
                                            this.sOpArray = new String[]{"购买", "查看"};
                                        }
                                        break;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                Tools.openRoamMenu(false, (byte) 1, (byte) 1, 3);

                            } else {
                                if ((this.bySelectIndex >= 1 && this.bySelectIndex <= 2) || this.bySelectIndex == 4) {
                                    //#if NOKIA_E72
                                    //#else
                                    this.getGoodsDescFromNet();
                                    //#endif
                                }
                            }
                        } else {
                            if (!(this.bySelectIndex <= 2 || this.bySelectIndex == 4)) {
                                this.bLock = false;
                                return;
                            } else {
                                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                    this.bLock = false;
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                    this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 0);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                    this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 1);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                                    this.bLock = false;
                                    switch (this.byMenuIndex) {
                                        case 0:
                                            //查看道具界面
                                            switch (this.bySelectIndex) {
                                                case 1:
                                                case 2:
                                                    GameBean.b_WAIT_NET_MSG_BACK = true;
                                                    MainLogic.getInstance().uiInterFace.sysMessage.checkStoreItem(this.myItems.getGoodsAlias(this.shPos), this.myItems.getGoodsColor(this.shPos), this.myItems.icon[this.shPos], this.myItems.getGoodsKey(this.shPos));
                                                    break;
                                                case 4:
                                                    //购买
                                                    //输入购买数量界面
                                                    //#if NOKIA_S60V5
                                                     MainLogic.getInstance().inputInterFace.setInputInterFace((byte) 1, "请输入要购买的物品数量:");
                                                     MainLogic.getInstance().inputInterFace.commonInput.setString(String.valueOf(1));
                                                     MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
                                                    //#else
//#                                                    this.byUiState = 1;
//#                                                    this.sArray[4] = "合计：0";
//#                                                    this.byBuyGoodsNum = 0;
                                                    //#endif
                                                    break;
                                            }
                                            break;
                                        case 1:
                                            GameBean.b_WAIT_NET_MSG_BACK = true;
                                            MainLogic.getInstance().uiInterFace.sysMessage.checkStoreItem(this.items.getGoodsAlias(this.shPos), this.items.getGoodsColor(this.shPos), this.items.icon[this.shPos], this.items.getGoodsKey(this.shPos));
                                            break;
                                    }
                                }
                            }
                        }
                    } else {
                        if (this.byState == 1 || this.byState == 2) {
                            iPositionY = Tools.updateLinePos(this.iArray, iPositionY);
                            if (this.iArray == null || this.iArray[1] == 0) {
                                this.byState = 0;
                                this.bKeypressLock = false;
                            }
                        }
                        MainCanvas.clearInput();
                    }
                }
                break;
            case 1:
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                    this.byUiState = 0;
                    if (this.byBuyGoodsNum < 1 || this.byBuyGoodsNum > 99) {
                        this.byBuyGoodsNum = 1;
                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您输入的数量不正确!");
                    } else {
                        //发送购买消息
                        this.buyIngotStoreGoods(byBuyGoodsNum);
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                    this.byUiState = 0;
                    this.byBuyGoodsNum = 0;
                } else {
                    this.byBuyGoodsNum = (byte) Tools.updateInputCanvas(this.byBuyGoodsNum, 99);
                    if (this.byBuyGoodsNum > -1) {
                        switch (this.bySelectIndex) {
                            case 1:
                            case 2:
                                this.sArray[4] = "合计：" + this.myItems.getGoodsPrice(this.shPos) * this.byBuyGoodsNum;
                                break;
                            case 4:
                                this.sArray[4] = "合计：" + this.items.getGoodsPrice(this.shPos) * this.byBuyGoodsNum;
                                break;
                        }
                    } else {
                        this.sArray[4] = "合计：0";
                    }
                }
                this.bFlag = this.bFlag ? false : true;
                break;
            case 2:
                break;
        }
        MainCanvas.clearInput();
    }

    public void drawIngotRecord(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[10], this.imgArray[11], this.imgArray[7], this.imgArray[9], sArray[0]);
         //绘制包裹栏和任务栏的背景
         iStartX = Constant.UI_START_X + 21;
         iStartY = this.iStartPointY;
         //出售物品背景
         //左面的
         Tools.drawTilePic(g, (byte) 2, iStartX, iStartY + 34, 270 - 34 - 13, this.imgArray[6], 14, 0, 13, 13, Constant.TRANS_NONE);
         //右面的
         Tools.drawTilePic(g, (byte) 2, iStartX + 318 - 13, iStartY + 35, 270 - 34 - 13, this.imgArray[6], 14, 0, 13, 13, Constant.TRANS_ROT180);
         //下面的
         Tools.drawTilePic(g, (byte) 1, iStartX + 13, iStartY + 270 - 13, 318 - 26, this.imgArray[6], 14, 14, 13, 13, Constant.TRANS_NONE);//下面
         //底部
         g.drawRegion(this.imgArray[6], 0, 14, 13, 13, Constant.TRANS_NONE, iStartX, iStartY + 270 - 13, 0); //左下角
         g.drawRegion(this.imgArray[6], 0, 14, 13, 13, Constant.TRANS_ROT270, iStartX + 318 - 13, iStartY + 270 - 13, 0); //右下角
         //填充中间的部分呢
         g.setColor(0x9c9c9c);
         g.fillRect(iStartX + 13, iStartY + 34, 292, 224);
 
         g.setColor(0x9c9c9c);
         g.fillRect(iStartX + 13, iStartY + 13, 130 - 26, 34 - 13);
         g.drawRegion(this.imgArray[6], 0, 0, 13, 13, Constant.TRANS_NONE, iStartX, iStartY, 0); //左上角
         g.drawRegion(this.imgArray[6], 0, 0, 13, 13, Constant.TRANS_ROT90, iStartX + 130 - 13, iStartY, 0); //右上角
         Tools.drawTilePic(g, (byte) 2, iStartX, iStartY + 13, 34 - 13, this.imgArray[6], 14, 0, 13, 13, Constant.TRANS_NONE);//左面
         Tools.drawTilePic(g, (byte) 2, iStartX + 130 - 13, iStartY + 13, 34 - 13, this.imgArray[6], 14, 0, 13, 13, Constant.TRANS_ROT180);//右面
         Tools.drawTilePic(g, (byte) 1, iStartX + 13, iStartY, 130 - 26, this.imgArray[6], 28, 0, 13, 13, Constant.TRANS_NONE);//上面
         Tools.drawTilePic(g, (byte) 1, iStartX + 130, iStartY + 34, 310 - 122, this.imgArray[6], 28, 0, 13, 13, Constant.TRANS_NONE);//上面
         //tab标题背景
         g.drawRegion(this.imgArray[6], 42, 0, 10, 24, Constant.TRANS_NONE, iStartX + 6, iStartY + 5, 0); //头
         g.drawRegion(this.imgArray[6], 42, 0, 10, 24, Constant.TRANS_ROT180, iStartX + 130 - 16, iStartY + 5, 0); //尾
         Tools.drawTilePic(g, (byte) 1, iStartX + 16, iStartY + 5, 130 - 32, this.imgArray[6], 53, 0, 10, 24, Constant.TRANS_NONE);//中间
         //绘制标题
         Tools.drawShadowString(g, (byte) 1, this.sArray[0], iStartX + ((130 - Constant.FONT_SMALL.stringWidth(this.sArray[1])) >> 1), iStartY + ((34 - Constant.FONT_SMALL_HEIGHT) >> 1), 0x00ccff, 0x000000);
         //开始绘制包裹中的内容
         iStartX = Constant.UI_START_X + 28;
         iStartY = this.iStartPointY + 38;
         //绘制商城商品
         for (byte i = 0; i < 14; i++) {
             //物品放置的索引位置
             if (i % 7 == 0) {
                 iStartX = Constant.UI_START_X + 28;
             }
             this.myItems.drawGoods(g, iStartX, iStartY, (short) ((this.byCurrentPage - 1) * 14 + i));
             //绘制的格子
             if (i % 7 == 6) {
                 iStartY = iStartY + 44;
             }
             iStartX = iStartX + 44;
         }
 
         //绘制翻页
         Tools.drawPage(g, this.byTotalPage, this.byCurrentPage, this.imgArray[4], this.imgArray[0], Constant.UI_START_X + 333 - Tools.getPageStrWidth(this.byTotalPage, this.byCurrentPage), iStartY + ((Constant.FONT_SMALL_HEIGHT - 9) >> 1));
         //绘制限时特卖
         iStartX = Constant.UI_START_X + 28;
         iStartY = iStartY + 44;
         Tools.drawShadowString(g, (byte) 1, this.sArray[6], iStartX + 3, iStartY - Constant.FONT_SMALL_HEIGHT - 2, 0x0099CC, 0x000000);
         for (byte i = 0; i < 7; i++) {
             this.items.drawGoods(g, iStartX, iStartY, i);
             iStartX += 44;
         }
         //绘制玩家的背包数量和空余背包数量//绘制玩家元宝数量
         Tools.setColor(g, 0xFFFFFF);
         g.drawString(this.sArray[1], Constant.UI_START_X + 28, Constant.UI_START_Y + 395, 0);
         g.drawString(this.sArray[2], Constant.UI_START_X + Constant.DRAW_WIDTH - 51 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + 395, 0);
         g.drawImage(this.imgArray[8], Constant.UI_START_X + Constant.DRAW_WIDTH - 48, Constant.UI_START_Y + 395 + ((Constant.FONT_SMALL_HEIGHT - 12) >> 1), 0);
         //绘制选中横条
         if (this.bySelectIndex == 3) {
             Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 38 + 88 + 15, Constant.DRAW_WIDTH);
         }
         //绘制物品的选中状态(最上层。防止被覆盖)
         switch (this.bySelectIndex) {
             case 1:
             case 2:
                 if (this.shPos >= 0) {
                     if (this.shPos % 7 == 0) {
                         this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1) + 6;
                         iStartY = this.iStartPointY + 38 + ((this.shPos - (this.byCurrentPage - 1) * 14) / 7) * 44;
                     } else {
                         this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1) + 6 + (this.shPos % 7) * 44;
                         iStartY = this.iStartPointY + 38 + ((this.shPos - (this.byCurrentPage - 1) * 14) / 7) * 44;
                     }
                     this.myItems.drawSelectStyle(g, iStartX, iStartY);
                     if (this.myItems.checkColumnHasGoods(this.shPos)) {
                         Tools.drawHCycleRollingParagraph(g, this.myItems.getGoodsDesc(this.shPos), this.iGoodsDescHeight, 290, 60, Constant.FONT_SMALL_HEIGHT, Constant.UI_START_X + 28, this.iStartPointY + 275, 0xFFFFFF, -1);
                         if (bLock) {
                             this.items.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, iStartX, iStartY);
                         } else {
                             Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH, this.imgArray[8], this.shTipsIngotPicStart);
                         }
                     }
                 }
                 break;
             case 4:
                 iStartX = Constant.UI_START_X + 28 + shPos * 44;
                 iStartY = this.iStartPointY + 38 + 44 * 3;
                 this.items.drawSelectStyle(g, iStartX, iStartY);
                 if (this.items.checkColumnHasGoods(this.shPos)) {
                     //物品的描述
                     Tools.drawHCycleRollingParagraph(g, this.items.getGoodsDesc(this.shPos), this.iGoodsDescHeight, 290, 60, Constant.FONT_SMALL_HEIGHT, Constant.UI_START_X + 28, this.iStartPointY + 275, 0xFFFFFF, -1);
                     if (bLock) {
                         Tools.drawPopMenu(g, this.sOpArray, (byte) 1, Constant.FONT_CHAR_WIDTH * 4 + 4, Constant.FONT_SMALL_HEIGHT, 0x000000, 0xFFFFFF, 0x0099cc, this.byMenuIndex, iStartX, iStartY);
                     } else {
                         Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH, this.imgArray[8], this.shTipsIngotPicStart);
                     }
                 }
                 break;
         }
        //#else
        //#if NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[2], this.sButton[0], this.sButton[1], this.sArray[0]);
        //#else
//#        Tools.drawFrame(g, this.imgArray[2], this.imgArray[1], this.sButton[0], this.sButton[1], this.sArray[0]);
        //#endif
//#        //绘制包裹栏和任务栏的背景
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1);
//#        iStartY = this.iStartPointY;
//#        //出售物品背景
//#        g.drawRegion(this.imgArray[6], 0, 0, 7, 7, Constant.TRANS_NONE, iStartX, iStartY, 0); //左上角
//#        g.drawRegion(this.imgArray[6], 7, 0, 7, 7, Constant.TRANS_NONE, iStartX + 82 - 7, iStartY, 0); //右上角
//#        g.drawRegion(this.imgArray[6], 0, 7, 7, 7, Constant.TRANS_NONE, iStartX, iStartY + 190, 0); //左下角
//#        g.drawRegion(this.imgArray[6], 7, 7, 7, 7, Constant.TRANS_NONE, iStartX + 232 - 7, iStartY + 190, 0); //右下角
//#        //绘制四周的边框
//#        //上面的边框
//#        Tools.drawTilePic(g, (byte) 1, iStartX + 7, iStartY, 68, this.imgArray[6], 21, 0, 6, 7, Constant.TRANS_NONE);
//#        Tools.drawTilePic(g, (byte) 1, iStartX + 82, iStartY + 29, 149, this.imgArray[6], 21, 0, 6, 7, Constant.TRANS_NONE);
//#        //下面
//#        Tools.drawTilePic(g, (byte) 1, iStartX + 7, iStartY + 190, 218, this.imgArray[6], 21, 7, 6, 7, Constant.TRANS_NONE);
//#        //左面
//#        Tools.drawTilePic(g, (byte) 2, iStartX, iStartY + 7, 183, this.imgArray[6], 14, 0, 7, 7, Constant.TRANS_NONE);
//#        //右面
//#        Tools.drawTilePic(g, (byte) 2, iStartX + 75, iStartY + 7, 22, this.imgArray[6], 14, 7, 7, 7, Constant.TRANS_NONE);
//#        Tools.drawTilePic(g, (byte) 2, iStartX + 225, iStartY + 30, 162, this.imgArray[6], 14, 7, 7, 7, Constant.TRANS_NONE);
//#        Tools.setColor(g, 0x989898);
//#        g.fillRect(iStartX + 7, iStartY + 7, 68, 29);
//#        g.fillRect(iStartX + 82 - 7, iStartY + 29, 7, 7);
//#        g.fillRect(iStartX + 7, iStartY + 36, 218, 159);
//#        g.drawRegion(this.imgArray[6], 27, 0, 5, 14, Constant.TRANS_NONE, iStartX + 3, iStartY + 7, 0); //头
//#        g.drawRegion(this.imgArray[6], 27, 0, 5, 14, Constant.TRANS_ROT180, iStartX + 82 - 3 - 5, iStartY + 7, 0); //尾
//#        Tools.drawTilePic(g, (byte) 1, iStartX + 3 + 5, iStartY + 7, 66, this.imgArray[6], 31, 0, 1, 14, Constant.TRANS_NONE);
//#        //绘制标题
//#        Tools.drawShadowString(g, (byte) 1, this.sArray[0], iStartX + ((82 - Constant.FONT_SMALL.stringWidth(this.sArray[0])) >> 1), iStartY + ((28 - Constant.FONT_SMALL_HEIGHT) >> 1), 0x00ccff, 0x000000);
//#        //开始绘制包裹中的内容
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#        iStartY = this.iStartPointY + 36;
//#        //绘制商城商品
//#        for (byte i = 0; i < 14; i++) {
//#            //物品放置的索引位置
//#            if (i % 7 == 0) {
//#                iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#            }
//#            this.myItems.drawGoods(g, iStartX, iStartY, (short) ((this.byCurrentPage - 1) * 14 + i));
//#            //绘制的格子
//#            if (i % 7 == 6) {
//#                iStartY = iStartY + 32;
//#            }
//#            iStartX = iStartX + 32;
//#        }
//#        //绘制翻页
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#        Tools.drawPage(g, this.byTotalPage, this.byCurrentPage, this.imgArray[4], this.imgArray[0], iStartX + 232 - 5 - Tools.getPageStrWidth(this.byTotalPage, this.byCurrentPage), iStartY + ((Constant.FONT_SMALL_HEIGHT - 9) >> 1) + 2);
//#
//#        //绘制限时特卖
//#        iStartY = this.iStartPointY + 29 + 32 * 3 + 18;
//#        Tools.drawShadowString(g, (byte) 1, this.sArray[6], iStartX + 3, iStartY - Constant.FONT_SMALL_HEIGHT - 2, 0x0099CC, 0x000000);
//#        for (byte i = 0; i < 7; i++) {
//#            this.items.drawGoods(g, iStartX, iStartY, (short) ((this.byCurrentPage - 1) * 14 + i));
//#            iStartX += 32;
//#        }
//#
//#        //绘制玩家的背包数量和空余背包数量
//#        Tools.setColor(g, 0xFFFFFF);
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1);
        //#if NOKIA_E72
//#         g.drawString(this.sArray[1], iStartX, Constant.UI_START_Y + Constant.DRAW_HEIGHT - Constant.FONT_SMALL_HEIGHT - 1, 0);
//#         g.drawString(this.sArray[2], iStartX + 232 - 20 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + Constant.DRAW_HEIGHT - Constant.FONT_SMALL_HEIGHT - 1, 0);
//#         g.drawImage(this.imgArray[8], iStartX + 232 - 18, Constant.UI_START_Y + Constant.DRAW_HEIGHT - Constant.FONT_SMALL_HEIGHT - 1 + ((Constant.FONT_SMALL_HEIGHT - 12) >> 1), 0);
        //#else
//#        g.drawString(this.sArray[1], Constant.UI_START_X + 10, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 24 - Constant.FONT_SMALL_HEIGHT, 0);
//#        g.drawString(this.sArray[2], Constant.UI_START_X + Constant.DRAW_WIDTH - 31 - Constant.FONT_SMALL.stringWidth(this.sArray[2]), Constant.UI_START_Y + Constant.DRAW_HEIGHT - 24 - Constant.FONT_SMALL_HEIGHT, 0);
//#        g.drawImage(this.imgArray[8], Constant.UI_START_X + Constant.DRAW_WIDTH - 29, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 24 - Constant.FONT_SMALL_HEIGHT + ((Constant.FONT_SMALL_HEIGHT - 12) >> 1), 0);
        //#endif
//#        //绘制玩家元宝数量
//#        //绘制选中横条
//#        if (this.bySelectIndex == 3) {
//#            Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + 36 + 62 + 15, Constant.DRAW_WIDTH);
//#        }
//#        //绘制物品的选中状态(最上层。防止被覆盖)
//#        switch (this.bySelectIndex) {
//#            case 1:
//#            case 2:
//#                if (this.shPos >= 0) {
//#                    if (this.shPos % 7 == 0) {
//#                        this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#                        iStartY = this.iStartPointY + 36 + ((this.shPos - (this.byCurrentPage - 1) * 14) / 7) * 32;
//#                    } else {
//#                        this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5 + (this.shPos % 7) * 32;
//#                        iStartY = this.iStartPointY + 36 + ((this.shPos - (this.byCurrentPage - 1) * 14) / 7) * 32;
//#                    }
//#                    this.myItems.drawSelectStyle(g, iStartX, iStartY);
//#                    if (this.myItems.checkColumnHasGoods(this.shPos)) {
//#                        //物品的描述
                        //#if NOKIA_E72
                        //#else
//#                        Tools.drawHCycleRollingParagraph(g, this.myItems.getGoodsDesc(this.shPos), this.iGoodsDescHeight, 209, 50 - 7, 16, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 229) >> 1) + 10, this.iStartPointY + 196 + 7, 0xFFFFFF, -1);
                        //#endif
//#                        if (bLock) {
//#                            Tools.drawPopMenu(g, this.sOpArray, (byte) 1, Constant.FONT_CHAR_WIDTH * 4 + 4, Constant.FONT_SMALL_HEIGHT, 0x000000, 0xFFFFFF, 0x0099cc, this.byMenuIndex, iStartX, iStartY);
//#                        } else {
//#                            Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH, this.imgArray[8], this.shTipsIngotPicStart);
//#                        }
//#                    }
//#                }
//#                break;
//#            case 4:
//#                if (this.shPos >= 0) {
//#                    iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5 + this.shPos * 32;
//#                    iStartY = this.iStartPointY + 48 + 32 * 3;
//#                    this.items.drawSelectStyle(g, iStartX, iStartY);
//#                    if (this.items.checkColumnHasGoods(this.shPos)) {
//#                        //物品的描述
                        //#if NOKIA_E72
                        //#else
//#                        Tools.drawHCycleRollingParagraph(g, this.items.getGoodsDesc(this.shPos), this.iGoodsDescHeight, 209, 50 - 7, 16, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 229) >> 1) + 10, this.iStartPointY + 196 + 7, 0xFFFFFF, -1);
                        //#endif
//#                        if (bLock) {
//#                            Tools.drawPopMenu(g, this.sOpArray, (byte) 1, Constant.FONT_CHAR_WIDTH * 4 + 4, Constant.FONT_SMALL_HEIGHT, 0x000000, 0xFFFFFF, 0x0099cc, this.byMenuIndex, iStartX, iStartY);
//#                        } else {
//#                            Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH, this.imgArray[8], this.shTipsIngotPicStart);
//#                        }
//#                    }
//#                }
//#                break;
//#        }
//#
//#        switch (this.byUiState) {
//#            case 1:
//#                //绘制弹出的输入数字界面
//#                drawInputCanvas(g, this.imgArray[7], (byte) 2, 232, 68, this.imgArray[6], this.imgArray[3], this.imgArray[3], this.sArray[5], 68, 18, this.byBuyGoodsNum, this.bFlag, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 68) >> 1), this.sArray[4], this.imgArray[8]);
//#                break;
//#            case 2:
//#                break;
//#        }
        //#endif
    }

    /**
     * 清除资源
     */
    public void clearIngotRecord() {
        this.store = null;
        this.sArray = null;
        this.iArray = null;
        this.items = null;
        this.sOpArray = null;
        this.byGetDataFromNet = null;
        this.sIngotTabTitle = null;
        this.sButton = null;
        this.sTips = null;

    }

    /**
     * 完成商品的购买
     */
    public void completeIngotBuy(byte stateCode, short shPlayerNowBag) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                this.shPlayerNowBag = shPlayerNowBag;
                this.sArray[1] = "背包：" + shPlayerNowBag + "/" + this.shPlayerBag;
                switch (MainLogic.getInstance().byGameState) {
                    case Constant.GAME_UI_INGOT_STORE:
                        switch (this.bySelectIndex) {
                            case 2:
                            case 3:
                                this.lMoney -= this.store[this.byTabIndex - 1].getGoodsPrice(this.shPos) * this.byBuyGoodsNum;
                                this.sArray[2] = "元宝：" + this.lMoney;
                                break;
                            case 5:
                                this.lMoney -= this.items.getGoodsPrice(this.shPos) * this.byBuyGoodsNum;
                                this.sArray[2] = "元宝：" + this.lMoney;
                                break;
                        }
                        break;
                    case Constant.GAME_UI_WAGE_STORE:
                        this.lMoney -= this.store[this.byTabIndex - 1].getGoodsPrice(this.shPos) * this.byBuyGoodsNum;
                        this.sArray[2] = "元宝：" + this.lMoney;
                        break;
                    case Constant.GAME_UI_INGOT_RECORD:
                        this.lMoney -= this.items.getGoodsPrice(this.shPos) * this.byBuyGoodsNum;
                        this.sArray[2] = "元宝：" + this.lMoney;
                        break;

                }
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "道具购买成功!");
                break;
            case 1://余额不足
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的元宝余额不足!");
                break;
            case 2://扣款失败
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "道具购买失败!!");
                break;
            case 3://背包空间不够
                break;
            default:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "道具购买失败!!");
                break;
        }
    }

    public void makeItemsTips(Goods items, short shPos, String sPrice, Image ingotPic) {
        short w = 0;
        this.shTipsW = (short) (Constant.FONT_SMALL.stringWidth(items.getGoodsAlias(shPos)));
        this.sTips = "<" + Tools.getColorReplaceLetter(Goods.getGoodsNameColor(items.getGoodsColor(this.shPos))) + items.getGoodsAlias(shPos) + ">";
        this.sTips += "|等级：" + items.getGoodsLevel(this.shPos);
        w = (short) (Constant.FONT_SMALL.stringWidth("|等级：" + items.getGoodsLevel(shPos)));
        this.shTipsW = this.shTipsW < w ? w : this.shTipsW;
        this.shTipsH = (short) (Constant.FONT_SMALL_HEIGHT << 1);
        if (sPrice != null) {
            this.shTipsH += (short) (Constant.FONT_SMALL_HEIGHT);
            this.sTips += "|" + sPrice;
            w = (short) (Constant.FONT_SMALL.stringWidth(sPrice));
            if (ingotPic != null) {
                this.shTipsIngotPicStart = (short) (w + 7);
                w = (short) (Constant.FONT_SMALL.stringWidth(sPrice) + 17);
            }
            this.shTipsW = this.shTipsW < w ? w : this.shTipsW;
        }
        if (this.shTipsW < 40) {
            this.shTipsW = 40;
        }
        this.shTipsW += 10;
        this.shTipsH += 10;

    }
    /********************************玩家摆摊系统*************************************************/
    public byte byGap;
    public int gold;
    public byte silver;
    public byte copper;
    public byte byFalshPlace;

    public void openStall(long playerID) {
        this.lTraderID = playerID;
        this.byStoreType = (byte) (playerID == MainLogic.getInstance().gamePlayer.lPlayerID ? 1 : 2);
        MainLogic.getInstance().pushState(Constant.GAME_UI_PLAYER_STALL, true);
        GameBean.L_PLAYER_ID = playerID;
        GameBean.b_WAIT_NET_MSG_BACK = true;
        MainLogic.getInstance().send(Constant.MSG_NET_CMD_BUSINESS_OPEN, Constant.SOCKET_MSG_TYPE_LOGIC);
    }

    public void initPlayerStall() {
//        this.byStoreType = 2;//当前是我自己的商店
//        this.items = new Goods((short) 14, Constant.ITEM_COLUMN_TYPE_COMMON);
//        this.items.addGoods((short) 0, true, -1, (short) -1, "下坡", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 1, true, -1, (short) -1, "下坡2", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 2, true, -1, (short) -1, "下坡3", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 3, true, -1, (short) -1, "下坡4", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.sShopTitle = "买东西";
        /***********************************/
        this.lMoney = 0;
        this.byState = 0;
        this.shPos = 0;
        bLock = false;
        this.bWaitMSGBack = false;
        this.bLock = false;
        if (this.byStoreType == 1) {
            bySelectIndex = 2;
            this.sArray = new String[]{"我的摊位", "选择货物上架", "(", "个)", "请输入购买数量"};
            this.sOpArray = new String[]{"修改", "下架"};
        } else {
            bySelectIndex = 1;
            this.sArray = new String[]{"摊位", "选择货物上架", "(", "个)", "请输入购买数量"};
            this.sOpArray = new String[]{"查看", "购买一个", "购买多个", "购买全部"};
        }
        this.shPos = 0;
        this.byBuyGoodsNum = 1;
        this.byMenuIndex = 0;
        this.byUiState = 0;
        this.sGoodsPrice = null;
        //界面中的位置的统一配置
        //#if NOKIA_S60V5
         byGap = 13;
         this.iStartPointY = Constant.UI_START_Y + 120;
         iPositionY = this.iStartPointY + 31 + byGap;
        //#elif NOKIA_E72
//#         byGap = 1;
//#         this.iStartPointY = Constant.UI_START_Y + 93;
//#         this.iPositionY = this.iStartPointY + 31;
        //#else
//#        byGap = 1;
//#        this.iStartPointY = Constant.UI_START_Y + 108;
//#        this.iPositionY = this.iStartPointY + 31;
        //#endif
        this.items = new Goods((short) 0, Constant.ITEM_COLUMN_TYPE_COMMON);
        try {
            //#if NOKIA_S60V5
             imgArray = new Image[14];
             this.imgArray[0] = ResManager.createImage(90000041);  //箭头图片
             this.imgArray[1] = Tools.makeBlueMask();   //蓝色光片
             this.imgArray[2] = ResManager.createImage(90000017); //背景图片
             this.imgArray[3] = ResManager.createImage(90000060);//确定取消图片
             this.imgArray[4] = ResManager.createImage(90000044);//文字图片
             this.imgArray[5] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角图片tishi.png
             this.imgArray[6] = Tools.makeTransparent(Constant.DRAW_WIDTH, 20, 180, 0x000000);
             this.imgArray[7] = ResManager.createImage(90000084);//方向键
             this.imgArray[8] = ResManager.createImage(90000085);//确认
             this.imgArray[9] = ResManager.createImage(90000086);//蓝条
             this.imgArray[10] = ResManager.createImage(90000043);//蓝条
             this.imgArray[11] = ResManager.createImage(90000063);//龙币
             this.imgArray[12] = ResManager.createImage(90000042);//金币图片
             this.imgArray[13] = ResManager.createImage(90000047);//数字图片
            //#else
//#            imgArray = new Image[10];
//#            this.imgArray[0] = ResManager.createImage(90000041);  //箭头图片
//#            this.imgArray[1] = Tools.makeBlueMask();   //蓝色光片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[2] = ResManager.createImage(90000017);
//# //            imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            this.imgArray[2] = ResManager.createImage(90000017); //背景图片
            //#endif
//#
//#            this.imgArray[3] = ResManager.createImage(90000043);//文字图片
//#            this.imgArray[4] = ResManager.createImage(90000044);//确定取消图片
//#            this.imgArray[5] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//提示框
//#            this.imgArray[6] = Tools.makeTransparent(Constant.DRAW_WIDTH, 20, 180, 0x000000);
//#            this.imgArray[7] = ResManager.createImage(90000063);//龙币
//#            this.imgArray[8] = ResManager.createImage(90000042);//金币图片
//#            this.imgArray[9] = ResManager.createImage(90000047);//数字图片
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
        this.sButton = new String[]{"确定", "返回"};
        this.setStallGoodsState();
    }

    public void updatePlayerStall() {
        if (GameBean.b_WAIT_NET_MSG_BACK) {
            return;
        }
        switch (this.byUiState) {
            case 0:
                if (!bKeypressLock) {
                    if (!bLock) {
                        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                            if (this.bySelectIndex > 1) {
                                this.bySelectIndex = (byte) (this.bySelectIndex - 1);
                                if (this.byStoreType == 1) {
                                    switch (this.bySelectIndex) {
                                        case 1:
                                            this.shPos = -1;
                                            break;
                                        default:
                                            this.shPos -= 7;
                                            this.setStallGoodsState();
                                            break;
                                    }
                                } else {
                                    this.shPos = (short) (this.shPos < 7 ? this.shPos : this.shPos - 7);
                                    this.setStallGoodsState();
                                }
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                            if (this.byStoreType == 1 && this.bySelectIndex < 5) {
                                this.bySelectIndex = (byte) (this.bySelectIndex + 1);
                                switch (this.bySelectIndex) {
                                    case 2:
                                        this.shPos = 0;
                                        this.setStallGoodsState();
                                        break;
                                    default:
                                        this.shPos += 7;
                                        this.setStallGoodsState();
                                        break;
                                }
                            } else if (this.byStoreType == 2 && this.bySelectIndex < 4) {
                                this.bySelectIndex = (byte) (this.bySelectIndex + 1);
                                this.shPos += 7;
                                this.setStallGoodsState();
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                            if (this.byStoreType == 1 && this.bySelectIndex > 1) {
                                this.shPos = (short) (this.shPos == 0 ? this.shPos : this.shPos - 1);
                                this.bySelectIndex = (byte) (this.shPos / 7 + 2);
                                this.setStallGoodsState();
                            } else if (this.byStoreType == 2) {
                                this.shPos = (short) (this.shPos == 0 ? this.shPos : this.shPos - 1);
                                this.bySelectIndex = (byte) (this.shPos / 7 + 1);
                                this.setStallGoodsState();
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                            if (this.bySelectIndex > 1) {
                                this.shPos = (short) (this.shPos == 27 ? this.shPos : this.shPos + 1);
                                this.bySelectIndex = (byte) (this.shPos / 7 + 2);
                                this.setStallGoodsState();
                            } else if (this.byStoreType == 2) {
                                this.shPos = (short) (this.shPos == 27 ? this.shPos : this.shPos + 1);
                                this.bySelectIndex = (byte) (this.shPos / 7 + 1);
                                this.setStallGoodsState();
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                            if (this.byStoreType == 1) {
                                switch (this.bySelectIndex) {
                                    case 1://选择上架货物
                                        if (this.items.getGoodsNum() == this.items.getMaxColumNum()) {
                                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的摊位已满，不能继续上货，请扩展摊位");
                                        } else {
                                            MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                                        }
                                        break;
                                    case 2:
                                    case 3:
                                    case 4:
                                    case 5:
                                        if (this.items.checkColumnHasGoods(shPos)) {
                                            this.byMenuIndex = 0;
                                            this.bLock = true;
                                        } else {
                                            MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                                        }
                                        break;
                                }
                            } else {
                                if (this.items.checkColumnHasGoods(shPos)) {
                                    this.byMenuIndex = 0;
                                    this.bLock = true;
                                }
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                            if (this.byStoreType == 1) {
                                //#if NOKIA_S60V5
                                 Tools.openRoamMenu(false, (byte) 1, (byte) 0, 12);
                                //#else
//#                                Tools.openRoamMenu(false, (byte) 2, (byte) 0, 2);
                                //#endif
                            } else {
                                Tools.openRoamMenu(true, (byte) -1, (byte) -1, -1);
                            }
                        }
                    } else {
                        if ((this.bySelectIndex == 1 && this.byStoreType == 1) || !this.items.checkColumnHasGoods(shPos)) {
                            this.bLock = false;
                            return;
                        } else {
                            if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                this.bLock = false;
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 0);
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 1);
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                                this.bLock = false;
                                if (this.byStoreType == 1) {
                                    switch (this.byMenuIndex) {
                                        case 0://调整
                                            this.bFlag = true;
                                            this.byFalshPlace = 1;
                                            this.gold = this.items.getGoodsPrice(shPos) / 10000;
                                            this.silver = (byte) ((this.items.getGoodsPrice(shPos) - this.gold * 10000) / 100);
                                            this.copper = (byte) (this.items.getGoodsPrice(shPos) - this.gold * 10000 - this.silver * 100);
                                            GameBean.BY_TYPE = 3;
                                            GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey(this.shPos);
                                            this.byUiState = 1;
                                            //#if NOKIA_S60V5
                                             MainLogic.getInstance().inputInterFace.setInputInterFace((byte) 1, "请输入物品新价格：");
                                             MainLogic.getInstance().inputInterFace.commonInput2.setString(String.valueOf(this.gold));
                                             MainLogic.getInstance().inputInterFace.commonInput3.setString(String.valueOf(this.silver));
                                             MainLogic.getInstance().inputInterFace.commonInput4.setString(String.valueOf(this.copper));
                                             MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
                                            //#endif
                                            break;
                                        case 1://下架
                                            GameBean.BY_TYPE = 2;
                                            GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey(shPos);
                                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_BUSINESS_OPT, Constant.SOCKET_MSG_TYPE_LOGIC);
                                            break;
                                    }
                                } else {
                                    switch (this.byMenuIndex) {
                                        case 0://查看//String sItemName, byte byItemColor, Image itemIcon, long lPlayerID, long lItemSlotkeyID
                                            MainLogic.getInstance().uiInterFace.sysMessage.checkStallItem(this.items.getGoodsAlias(this.shPos), this.items.getGoodsColor(shPos), this.items.icon[this.shPos], this.lTraderID, (byte) this.shPos);
                                            break;
                                        case 1://购买一个 
                                            GameBean.b_WAIT_NET_MSG_BACK = true;
                                            GameBean.L_PLAYER_ID = this.lTraderID;
                                            GameBean.BY_GOODS_NUM = 1;
                                            GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey(shPos);
                                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_BUSINESS_BUY, Constant.SOCKET_MSG_TYPE_LOGIC);
                                            break;
                                        case 2://购买多个
                                            this.byUiState = 2;
                                            this.byBuyGoodsNum = 1;
                                            GameBean.L_PLAYER_ID = this.lTraderID;
                                            GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey(shPos);
                                            //#if NOKIA_S60V5
                                             MainLogic.getInstance().inputInterFace.setInputInterFace((byte) 2, "请输入要购买的数量：");
                                             MainLogic.getInstance().inputInterFace.commonInput.setString(String.valueOf(1));
                                             MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
                                            //#endif
                                            break;
                                        case 3://购买全部
                                            GameBean.L_PLAYER_ID = this.lTraderID;
                                            GameBean.BY_GOODS_NUM = (byte) this.items.getGoodsStackNum(shPos);
                                            GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey(shPos);
                                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_BUSINESS_BUY, Constant.SOCKET_MSG_TYPE_LOGIC);
                                            break;
                                    }
                                }
                            }
                        }
                    }
                } else {
                    if (this.byState == 1 || this.byState == 2) {
                        iPositionY = Tools.updateLinePos(this.iArray, iPositionY);
                        if (this.iArray == null || this.iArray[1] == 0) {
                            this.byState = 0;
                            this.bKeypressLock = false;
                        }
                    }
                    MainCanvas.clearInput();
                }


                break;
            case 1:
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                    this.byUiState = 0;
                    GameBean.I_MONEY = (this.gold > 0 ? this.gold * 10000 : 0) + (this.silver > 0 ? this.silver * 100 : 0) + (this.copper > 0 ? this.copper : 0);
                    this.items.iPrice[this.shPos] = GameBean.I_MONEY;
                    this.sGoodsPrice = "售价：" + Tools.moneyConvert(GameBean.I_MONEY) + " / 个";
                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_BUSINESS_OPT, Constant.SOCKET_MSG_TYPE_LOGIC);
                    //发送调整信息
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                    byFalshPlace = (byte) (byFalshPlace == 1 ? 3 : byFalshPlace - 1);
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                    byFalshPlace = (byte) (byFalshPlace == 3 ? 1 : byFalshPlace + 1);
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                    this.byUiState = 0;
                } else {
                    switch (this.byFalshPlace) {
                        case 1:
                            this.gold = Tools.updateInputCanvas(this.gold, 9999);
                            break;
                        case 2:
                            this.silver = (byte) Tools.updateInputCanvas(this.silver, 99);
                            break;
                        case 3:
                            this.copper = (byte) Tools.updateInputCanvas(this.copper, 99);
                            break;
                    }
                }
                this.bFlag = this.bFlag ? false : true;
                break;
            case 2:
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                    this.byUiState = 0;
                    if (this.byBuyGoodsNum < 1 || this.byBuyGoodsNum > this.items.getGoodsStackNum(shPos)) {
                        this.byBuyGoodsNum = 1;
                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您输入的数量不正确!");
                    } else {
                        //发送购买消息
                        if (this.items.getGoodsPrice(shPos) * this.byBuyGoodsNum > this.lMoney) {
                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的金币数量不够!");
                            return;
                        }
                        GameBean.BY_GOODS_NUM = this.byBuyGoodsNum;

                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_BUSINESS_BUY, Constant.SOCKET_MSG_TYPE_LOGIC);
//                        this.buyIngotStoreGoods(byBuyGoodsNum);
//                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "购买成功!");
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                    this.byUiState = 0;
                    this.byBuyGoodsNum = 0;
                } else {
                    this.byBuyGoodsNum = (byte) Tools.updateInputCanvas(this.byBuyGoodsNum, this.items.getGoodsStackNum(shPos));
                }
                this.bFlag = this.bFlag ? false : true;
                break;
        }
    }
    private static int[][] mStallRect;
    public void checkTouchPlayerStall(int x,int y) {
    	if (mStallRect == null) {
    		mStallRect = new int[28][];
    		iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - (31 + byGap) * 7 - 3) >> 1);
            iStartY = this.iStartPointY;
            for (byte i = 0; i < 4; i++) {
            	for (byte j=0;j<7;j ++) {
            	mStallRect[i*7 + j] = new int[]{
            			iStartX+(31 + byGap)*j, iStartY+(31 + byGap)*i,31 + byGap,31 + byGap,
            	};
            	}
//                //物品放置的索引位置
//                if (i % 7 == 0) {
//                    iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - (31 + byGap) * 7 - 3) >> 1);
//                }
//                items.drawGoods(g, iStartX, iStartY, i);
//                if (i == this.shPos) {
//                    this.items.drawSelectStyle(g, iStartX, iStartY);
//                }
//                //绘制的格子
//                if (i % 7 == 6) {
//                    iStartY += 31 + byGap;
//                }
//                iStartX += 31 + byGap;
            }
    	}
    	int touched = MainCanvas.checkTouch(x, y, mStallRect);
    	if (touched >= 0) {
    		if (this.shPos == touched) {
    			MainCanvas.pressFire();
    		} else {
	    		this.bySelectIndex = (byte) ((touched%7)+1);
	            this.shPos = (short) touched;
    		}
    	} else {
    		MainCanvas.checkSoftKey();
    	}
        
    }
    public void drawPlayerStall(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[7], this.imgArray[8], this.imgArray[9], this.imgArray[10], this.sArray[0]);
        //#elif NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[2], sButton[0], sButton[1], this.sArray[0]);
        //#else
//#        Tools.drawFrame(g, this.imgArray[2], this.imgArray[1], sButton[0], sButton[1], this.sArray[0]);
        //#endif
        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - (31 + byGap) * 7 - 3) >> 1);
        iStartY = this.iStartPointY;
        for (byte i = 0; i < 28; i++) {
            //物品放置的索引位置
            if (i % 7 == 0) {
                iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - (31 + byGap) * 7 - 3) >> 1);
            }
            items.drawGoods(g, iStartX, iStartY, i);
            if (i == this.shPos) {
                this.items.drawSelectStyle(g, iStartX, iStartY);
            }
            //绘制的格子
            if (i % 7 == 6) {
                iStartY += 31 + byGap;
            }
            iStartX += 31 + byGap;
        }

        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - (31 + byGap) * 7 - 3) >> 1);
        //#if NOKIA_S60V5
         Tools.drawMoney(g, this.lMoney, this.imgArray[11], this.imgArray[12], this.imgArray[13], iStartX, iStartY + 3);
         iStartY = Constant.UI_START_Y + 50;
         if (this.byStoreType == 1 && this.bySelectIndex == 1) {
             Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, iStartY + Constant.FONT_SMALL_HEIGHT + 5, Constant.DRAW_WIDTH);
         }
        //#elif NOKIA_E72
//#         Tools.drawMoney(g, this.lMoney, this.imgArray[7], this.imgArray[8], this.imgArray[9], iStartX, iStartY + 3);
//#         iStartY = Constant.UI_START_Y + 24;
//#         if (this.byStoreType == 1 && this.bySelectIndex == 1) {
//#             Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, iStartY + Constant.FONT_SMALL_HEIGHT + 5, Constant.DRAW_WIDTH);
//#         }
        //#else 
//#        Tools.drawMoney(g, this.lMoney, this.imgArray[7], this.imgArray[8], this.imgArray[9], iStartX, iStartY + 3);
//#        iStartY = Constant.UI_START_Y + 30;
//#        if (this.byStoreType == 1 && this.bySelectIndex == 1) {
//#            Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, iStartY + Constant.FONT_SMALL_HEIGHT + 5, Constant.DRAW_WIDTH);
//#        }
        //#endif
        if (this.byStoreType == 1) {
            Tools.drawShadowString(g, (byte) 1, this.sArray[1], iStartX, iStartY, 0x00CCFF, 0x000000);
        }
        iStartY += Constant.FONT_SMALL_HEIGHT + 5;
        if (this.items != null && this.items.checkColumnHasGoods(this.shPos)) {
            this.items.drawGoodsName(g, this.shPos, iStartX, iStartY);
            Tools.drawShadowString(g, (byte) 1, this.sArray[2] + this.items.getGoodsStackNum(shPos) + this.sArray[3], iStartX + Constant.FONT_SMALL.stringWidth(this.items.getGoodsAlias(shPos)), iStartY, 0xFFFFFF, 0x000000);
            iStartY += Constant.FONT_SMALL_HEIGHT + 5;
            Tools.drawShadowString(g, (byte) 1, this.sGoodsPrice, iStartX, iStartY, 0xFFFFFF, 0x000000);
            if (this.bLock) {
                iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - (31 + byGap) * 7 - 3) >> 1);
                iStartX = this.shPos % 7 == 0 ? iStartX : iStartX + (this.shPos % 7) * (31 + byGap);
                iStartY = this.iStartPointY + (this.shPos / 7) * (31 + byGap);
                Goods.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, iStartX, iStartY);
            } //
            //#if NOKIA_S60V5
            //#else
//#            else if (this.byUiState == 1 && this.byStoreType == 1) {//绘制调整价格界面
//#                iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - (31 + byGap) * 7 - 3) >> 1);
//#                iStartX = this.shPos % 7 == 0 ? iStartX : iStartX + (this.shPos % 7) * (31 + byGap);
//#                iStartY = this.iStartPointY + (this.shPos / 7) * (31 + byGap);
//#                Tools.drawPriceInput(g, iStartX, iStartY, this.gold, this.silver, this.copper, this.bFlag, this.byFalshPlace, this.imgArray[3]);
//#
//#            } else if (this.byUiState == 2) {
//#                //输入购买数量
//#                Tools.drawInputCanvas(g, this.imgArray[6], (byte) 2, 232, 65, this.imgArray[5], this.imgArray[4], 0, 0, 22, 10, this.imgArray[4], 22, 0, 21, 10, 0x989898, this.sArray[4], 65, Constant.FONT_SMALL_HEIGHT + 4, this.byBuyGoodsNum, this.bFlag, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_WIDTH - 65) >> 1));
//#            }
            //#endif
        }
        MainView.drawTouchRect(g, mStallRect);
    }

    public void clearPlayerStall() {
        this.imgArray = null;
        this.iArray = null;
        this.sArray = null;
        this.sOpArray = null;
        this.items = null;
        this.bTradeLock = null;
        this.sButton = null;
        this.sTips = null;
    }

    public void setStallGoodsState() {
        if (this.items != null && this.items.checkColumnHasGoods(this.shPos)) {
            this.sGoodsPrice = "售价：" + Tools.moneyConvert(this.items.getGoodsPrice(this.shPos)) + " / 个";
        }
    }

    //购买物品成功
    public void buyStallItems(byte stateCode, byte byNum, byte index) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        if (MainLogic.getInstance().byGameState != Constant.GAME_UI_PLAYER_STALL) {
            return;
        }
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品购买失败!");
                break;
            case 1:
                this.lMoney -= this.items.getGoodsPrice(shPos) * this.byBuyGoodsNum;
                if (byNum > 0) {
                    this.items.shStackNum[this.shPos] = byNum;
                } else {
                    this.items.deleteGoods(shPos);
                }
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品购买成功!");
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的金币不足!");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的背包已满!");
                break;
            case 4:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品不存在!");
                break;
            case 5:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品数量不足!");
                break;
            case 9:
                if (byNum > 0) {
                    this.items.shStackNum[this.shPos] = byNum;
                } else {
                    this.items.deleteGoods(shPos);
                }
                break;
        }
    }

    /*************************************************************************************************/
    public void stallItemsOpt(byte stateCode, byte index) {
        if (MainLogic.getInstance().byGameState != Constant.GAME_UI_PLAYER_STALL) {
            return;
        }
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "操作失败!");
                break;
            case 1:
                if (MainLogic.getInstance().uiPackage.bShowBAG) {
                    this.items.goodsClone(index, MainLogic.getInstance().uiPackage.getCurrentPackage(), MainLogic.getInstance().uiPackage.shPos);
                    this.items.iPrice[index] = GameBean.I_MONEY;
                    this.setStallGoodsState();
                    MainLogic.getInstance().uiPackage.getCurrentPackage().deleteGoods(MainLogic.getInstance().uiPackage.shPos);
                }
//                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "价格修改成功!");
                break;
            case 2:
                this.items.deleteGoods(shPos);
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的背包已经满了，请清理背包!");
                break;
            case 4:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的摊位已满，不能继续上货，请扩展摊位!");
                break;
            case 5:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "该物品不可以交易!");
                break;
            case 6:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "找不到这个物品!");
                break;
        }

    }
    
    //////////////////////////
    //
    
    public static final int BOX_SIZE = 40;
    public static final int START_X = 27;
    public static final int START_Y = 82;
    public static final int SPACE = 4;
    
    public static int[][] mPackagePageTouchRect = new int[][]{
      	{270,257,35,18},
      	{310,257,35,18},
      	
      };
    
    
      
      public static int[][] mPackageOperateRect;
    
    public static int[][] mPackageTouchRect = new int[][]{
    	//1
    	{START_X,START_Y,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE),START_Y,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 2,START_Y,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 3,START_Y,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 4,START_Y,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 5,START_Y,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 6,START_Y,BOX_SIZE,BOX_SIZE},
    	//2
    	{START_X,START_Y + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE),START_Y + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 2,START_Y + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 3,START_Y + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 4,START_Y + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 5,START_Y + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 6,START_Y + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
    	//3
    	{START_X,START_Y + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE),START_Y + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 2,START_Y + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 3,START_Y + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 4,START_Y + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 5,START_Y + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 6,START_Y + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
    	//4
    	{START_X,START_Y + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE),START_Y + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 2,START_Y + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 3,START_Y + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 4,START_Y + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 5,START_Y + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 6,START_Y + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
    	
    	
    	
    };


    public void checkTouchStoreBuy(int x, int y)
    {
    	if(bLock)
    	{
	    	mPackageOperateRect = Tools.getPopMenuTouch(sOpArray, (byte) 1,
					Constant.FONT_SMALL.stringWidth("查看") + 2,
					Constant.FONT_SMALL_HEIGHT + 1, 0x000000,
					0xFFFFFF, 0x00CCFF, this.byMenuIndex, iStartX,
					iStartY);
	    	
	    	int touched = MainCanvas.checkTouch(x, y, mPackageOperateRect);
	    	if(touched >= 0)
	    	{
	    		byMenuIndex = (byte) touched;
	    		MainCanvas.pressFire();
	    	}
	    	else
	    	{
	    		MainCanvas.pressBack();
	    	}
    	}
    	else   		
    	{
			int touched = MainCanvas.checkTouch(x, y, mPackagePageTouchRect);
			if (touched >= 0) 
			{
				bySelectIndex = 5;
				if (touched == 0) {
					if (byCurrentPage > 1) {
						byCurrentPage--;
						shPos = -1;
					}
				} else {
					if (byCurrentPage < byTotalPage) {
						byCurrentPage++;
						shPos = -1;
					}
				}

			} 
			else 
			{
				 touched = MainCanvas.checkTouch(x, y, mPackageTouchRect);
        		 if(touched>=0)
            	 {
        			 if (shPos == (byte) (short) (touched + (byCurrentPage - 1) * 28)) {
        				 MainCanvas.pressFire();
        			 } else 
        			 {
            			bySelectIndex = (byte) (touched/7 + 1);
            			shPos = (short) (touched + (byCurrentPage - 1) * 28);
						this.setGoodsState(this.items, this.shPos);
        			 }
            	 }
        		 else
        		 {
        			 MainCanvas.checkSoftKey();
        		 }
			}
		}
    }
    
    //////////////////////
    //
    
//  public static final int BOX_SIZE = 40;
  public static final int START_X_2 = 28;
  public static final int START_Y_2 = 150;
//  public static final int SPACE = 4;
  
  public static int[][] mPackagePageTouchRect2 = new int[][]{
    	{270,322,35,18},
    	{310,322,35,18},
    	
    };
  
  public static int[][] mGetAllTouchRect = new int[][]{
    	{10,340,90,30},
    	
    };

  public static int[][] mPackageTouchRect2 = new int[][]{
  	//1
  	{START_X_2,START_Y_2,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE),START_Y_2,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 2,START_Y_2,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 3,START_Y_2,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 4,START_Y_2,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 5,START_Y_2,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 6,START_Y_2,BOX_SIZE,BOX_SIZE},
  	//2
  	{START_X_2,START_Y_2 + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE),START_Y_2 + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 2,START_Y_2 + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 3,START_Y_2 + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 4,START_Y_2 + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 5,START_Y_2 + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 6,START_Y_2 + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
  	//3
  	{START_X_2,START_Y_2 + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE),START_Y_2 + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 2,START_Y_2 + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 3,START_Y_2 + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 4,START_Y_2 + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 5,START_Y_2 + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 6,START_Y_2 + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
  	//4
  	{START_X_2,START_Y_2 + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE),START_Y_2 + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 2,START_Y_2 + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 3,START_Y_2 + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 4,START_Y_2 + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 5,START_Y_2 + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
  	{START_X_2 + (BOX_SIZE + SPACE) * 6,START_Y_2 + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},

  	
  };
    
    public void checkTouchWareHouse(int x, int y)
    {
    	int touched = MainCanvas.checkTouch(x, y, mPackagePageTouchRect2);
		if (touched >= 0) 
		{
			bySelectIndex = 5;
			if (touched == 0) {
				if (byCurrentPage > 1) {
					byCurrentPage--;
					shPos = -1;
				}
			} else {
				if (byCurrentPage < byTotalPage) {
					byCurrentPage++;
					shPos = -1;
				}
			}

		} 
		else
		{
			touched = MainCanvas.checkTouch(x, y, mGetAllTouchRect);
			if(touched >= 0)
			{
				 bySelectIndex = 6;
				 MainCanvas.pressFire();
			}
			else
			{
				touched = MainCanvas.checkTouch(x, y, mPackageTouchRect2);
	       		 if(touched>=0)
	           	 {
	       			 if (shPos == (byte) (short) (touched + (byCurrentPage - 1) * 28)) {
	       				 MainCanvas.pressFire();
	       			 } 
	       			 else 
	       			 {
	           			bySelectIndex = (byte) (touched/7 + 1);
	           			shPos = (short) (touched + (byCurrentPage - 1) * 28);
						setGoodsState(this.items, this.shPos);
	       			 }
	           	 }
	       		 else
	       		 {
	       			 MainCanvas.checkSoftKey();
	       		 }
			}
			
		}
    }
}
